38
|
1 /*
|
|
2 * SDL_sound -- An abstract sound format decoding API.
|
|
3 * Copyright (C) 2001 Ryan C. Gordon.
|
|
4 *
|
|
5 * This library is free software; you can redistribute it and/or
|
|
6 * modify it under the terms of the GNU Lesser General Public
|
|
7 * License as published by the Free Software Foundation; either
|
|
8 * version 2.1 of the License, or (at your option) any later version.
|
|
9 *
|
|
10 * This library is distributed in the hope that it will be useful,
|
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 * Lesser General Public License for more details.
|
|
14 *
|
|
15 * You should have received a copy of the GNU Lesser General Public
|
|
16 * License along with this library; if not, write to the Free Software
|
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 */
|
|
19
|
|
20 /*
|
|
21 Attention: This is a stripped down file of SDL_endian for our purposes.
|
|
22 This code is licensed under the LGPL.
|
|
23 This means we must not compile this code into anything that we are not willing to
|
|
24 publicly release source code.
|
|
25 You should compile this into a separate dynamic library that is isolated from proprietary code.
|
|
26 */
|
|
27
|
|
28
|
|
29 #include <stdint.h>
|
|
30 #include "SoundDecoder.h"
|
|
31
|
|
32 uint32_t __Sound_convertMsToBytePos(Sound_AudioInfo *info, uint32_t ms)
|
|
33 {
|
|
34 /* "frames" == "sample frames" */
|
|
35 float frames_per_ms = ((float) info->rate) / 1000.0f;
|
|
36 uint32_t frame_offset = (uint32_t) (frames_per_ms * ((float) ms));
|
|
37 uint32_t frame_size = (uint32_t) ((info->format & 0xFF) / 8) * info->channels;
|
|
38 return(frame_offset * frame_size);
|
|
39 } /* __Sound_convertMsToBytePos */
|
|
40
|
|
41
|