Mercurial > SDL_sound_CoreAudio
annotate mixer/converters.c @ 570:d48126606f4d
Removed public attribute from some internal Timidity symbols.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 05 Jan 2010 15:05:57 -0500 |
parents | 2e8907ff98e9 |
children |
rev | line source |
---|---|
486
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
1 /* |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
2 * SDL_sound -- An sound processing toolkit. |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
3 * Copyright (C) 2001 Ryan C. Gordon. |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
4 * |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
5 * This library is free software; you can redistribute it and/or |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
6 * modify it under the terms of the GNU Lesser General Public |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
7 * License as published by the Free Software Foundation; either |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
8 * version 2.1 of the License, or (at your option) any later version. |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
9 * |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
10 * This library is distributed in the hope that it will be useful, |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
13 * Lesser General Public License for more details. |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
14 * |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU Lesser General Public |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
16 * License along with this library; if not, write to the Free Software |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
18 */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
19 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
20 /** |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
21 * This file implements the mixer itself. Largely, this is handled in the |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
22 * SDL audio callback. |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
23 * |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
24 * Documentation is in SDL_sound.h ... It's verbose, honest. :) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
25 * |
552
2e8907ff98e9
Replaced references to COPYING with references to LICENSE.txt ...
Ryan C. Gordon <icculus@icculus.org>
parents:
526
diff
changeset
|
26 * Please see the file LICENSE.txt in the source's root directory. |
486
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
27 * |
526
2df1f5c62d38
Updated my email address.
Ryan C. Gordon <icculus@icculus.org>
parents:
486
diff
changeset
|
28 * This file written by Ryan C. Gordon. (icculus@icculus.org) |
486
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
29 */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
30 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
31 #if HAVE_CONFIG_H |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
32 # include <config.h> |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
33 #endif |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
34 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
35 #include <stdio.h> |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
36 #include <stdlib.h> |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
37 #include <string.h> |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
38 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
39 #include "SDL.h" |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
40 #include "SDL_thread.h" |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
41 #include "SDL_sound.h" |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
42 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
43 #define __SDL_SOUND_INTERNAL__ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
44 #include "SDL_sound_internal.h" |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
45 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
46 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
47 static void conv_mix_buf_u8_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
48 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
49 register Uint8 *stream = _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
50 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
51 register Uint32 max = len * 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
52 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
53 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
54 *stream = (Uint8) ((((mixbuf[i]+mixbuf[i+1])*0.5f) * 127.0f) + 128.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
55 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
56 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
57 } /* conv_mix_buf_s8s */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
58 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
59 static void conv_mix_buf_s8_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
60 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
61 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
62 register Sint8 *stream = (Sint8 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
63 register Uint32 max = len * 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
64 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
65 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
66 *stream = (Sint8) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 127.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
67 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
68 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
69 } /* conv_mix_buf_s8s */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
70 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
71 static void conv_mix_buf_s16_lsb_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
72 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
73 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
74 register Sint16 *stream = (Sint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
75 register Sint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
76 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
77 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
78 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
79 val = (Sint16) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 32767.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
80 *stream = SDL_SwapLE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
81 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
82 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
83 } /* conv_mix_buf_s16_lsb_mono */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
84 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
85 static void conv_mix_buf_s16_msb_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
86 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
87 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
88 register Sint16 *stream = (Sint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
89 register Sint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
90 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
91 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
92 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
93 val = (Sint16) (((mixbuf[i] + mixbuf[i+1]) * 0.5f) * 32767.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
94 *stream = SDL_SwapBE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
95 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
96 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
97 } /* conv_mix_buf_s16_msb_mono */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
98 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
99 static void conv_mix_buf_u16_lsb_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
100 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
101 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
102 register Uint16 *stream = (Uint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
103 register Uint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
104 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
105 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
106 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
107 val = (Uint16)((((mixbuf[i]+mixbuf[i+1])*0.5f) * 32767.0f) + 32768.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
108 *stream = SDL_SwapLE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
109 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
110 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
111 } /* conv_mix_buf_s16_lsb_mono */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
112 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
113 static void conv_mix_buf_u16_msb_mono(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
114 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
115 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
116 register Uint16 *stream = (Uint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
117 register Uint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
118 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
119 for (i = 0; i < max; i += 2) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
120 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
121 val = (Uint16)((((mixbuf[i]+mixbuf[i+1])*0.5f) * 32767.0f) + 32768.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
122 *stream = SDL_SwapBE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
123 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
124 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
125 } /* conv_mix_buf_s16_lsb_mono */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
126 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
127 static void conv_mix_buf_u8_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
128 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
129 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
130 register Uint8 *stream = _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
131 register Uint32 max = len; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
132 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
133 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
134 *stream = (Uint8) ((mixbuf[i] * 127.0f) + 128.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
135 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
136 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
137 } /* conv_mix_buf_s8s */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
138 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
139 static void conv_mix_buf_s8_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
140 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
141 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
142 register Sint8 *stream = (Sint8 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
143 register Uint32 max = len; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
144 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
145 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
146 *stream = (Sint8) (mixbuf[i] * 127.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
147 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
148 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
149 } /* conv_mix_buf_s8s */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
150 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
151 static void conv_mix_buf_s16lsb_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
152 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
153 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
154 register Sint16 *stream = (Sint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
155 register Sint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
156 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
157 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
158 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
159 val = (Sint16) (mixbuf[i] * 32767.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
160 *stream = SDL_SwapLE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
161 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
162 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
163 } /* conv_mix_buf_s16_lsb_stereo */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
164 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
165 static void conv_mix_buf_s16msb_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
166 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
167 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
168 register Sint16 *stream = (Sint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
169 register Sint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
170 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
171 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
172 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
173 val = (Sint16) (mixbuf[i] * 32767.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
174 *stream = SDL_SwapBE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
175 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
176 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
177 } /* conv_mix_buf_s16_msb_stereo */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
178 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
179 static void conv_mix_buf_u16lsb_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
180 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
181 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
182 register Uint16 *stream = (Uint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
183 register Uint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
184 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
185 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
186 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
187 val = (Uint16) ((mixbuf[i] * 32767.0f) + 32768.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
188 *stream = SDL_SwapLE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
189 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
190 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
191 } /* conv_mix_buf_s16_lsb_stereo */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
192 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
193 static void conv_mix_buf_u16msb_stereo(void *userdata, Uint8 *_stream, int len) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
194 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
195 register Uint32 i; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
196 register Uint16 *stream = (Uint16 *) _stream; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
197 register Uint16 val; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
198 register Uint32 max = len / 2; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
199 for (i = 0; i < max; i++) |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
200 { |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
201 val = (Uint16) ((mixbuf[i] * 32767.0f) + 32768.0f); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
202 *stream = SDL_SwapBE16(val); |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
203 stream++; |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
204 } /* for */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
205 } /* conv_mix_buf_s16_msb_stereo */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
206 |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
207 /* end of converters.c ... */ |
859dd2ef3197
Added some seriously INCOMPLETE mixer code.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff
changeset
|
208 |