Mercurial > almixer_isolated
view Isolated/LGPL/SDL_sound_minimal.c @ 62:7a4a8459f0c1
Ogg Vorbis decoder for SoundDecoder directly adapted from SDL_sound's code. Thanks to Johnson Lin for providing this!
Instead of trying to backport my Tremor decoder which originated from the SDL_sound Vorbis decoder, I told Johnson it would be better to just start at the source and avoid all the original gotchas I hit in the subtle differences between Tremor and Vorbis.
Since this derives directly from Ryan Gordon's SDL_sound implementation, I am putting this under the LGPL subdirectory.
Johnson Lin < arch . jslin - at - gmail . com >
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Tue, 19 Jun 2012 00:31:12 -0700 |
parents | 71b465ff0622 |
children | 96c61ac12446 |
line wrap: on
line source
/* * SDL_sound -- An abstract sound format decoding API. * Copyright (C) 2001 Ryan C. Gordon. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Attention: This is a stripped down file of SDL_endian for our purposes. This code is licensed under the LGPL. This means we must not compile this code into anything that we are not willing to publicly release source code. You should compile this into a separate dynamic library that is isolated from proprietary code. */ #include <stdint.h> #include "SoundDecoder.h" uint32_t __Sound_convertMsToBytePos(Sound_AudioInfo *info, uint32_t ms) { /* "frames" == "sample frames" */ float frames_per_ms = ((float) info->rate) / 1000.0f; uint32_t frame_offset = (uint32_t) (frames_per_ms * ((float) ms)); uint32_t frame_size = (uint32_t) ((info->format & 0xFF) / 8) * info->channels; return(frame_offset * frame_size); } /* __Sound_convertMsToBytePos */