Mercurial > sdl-ios-xcode
annotate src/audio/SDL_audiocvt.c @ 1402:d910939febfa
Use consistent identifiers for the various platforms we support.
Make sure every source file includes SDL_config.h, so the proper system
headers are chosen.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 21 Feb 2006 08:46:50 +0000 |
parents | c71e05b4dc2e |
children | 5f52867ba65c |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 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 | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1011
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Functions for audio drivers to perform runtime conversion of audio format */ | |
25 | |
26 #include "SDL_audio.h" | |
27 | |
28 | |
29 /* Effectively mix right and left channels into a single channel */ | |
30 void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format) | |
31 { | |
32 int i; | |
33 Sint32 sample; | |
34 | |
35 #ifdef DEBUG_CONVERT | |
36 fprintf(stderr, "Converting to mono\n"); | |
37 #endif | |
38 switch (format&0x8018) { | |
39 | |
40 case AUDIO_U8: { | |
41 Uint8 *src, *dst; | |
42 | |
43 src = cvt->buf; | |
44 dst = cvt->buf; | |
45 for ( i=cvt->len_cvt/2; i; --i ) { | |
46 sample = src[0] + src[1]; | |
47 if ( sample > 255 ) { | |
48 *dst = 255; | |
49 } else { | |
50 *dst = sample; | |
51 } | |
52 src += 2; | |
53 dst += 1; | |
54 } | |
55 } | |
56 break; | |
57 | |
58 case AUDIO_S8: { | |
59 Sint8 *src, *dst; | |
60 | |
61 src = (Sint8 *)cvt->buf; | |
62 dst = (Sint8 *)cvt->buf; | |
63 for ( i=cvt->len_cvt/2; i; --i ) { | |
64 sample = src[0] + src[1]; | |
65 if ( sample > 127 ) { | |
66 *dst = 127; | |
67 } else | |
68 if ( sample < -128 ) { | |
69 *dst = -128; | |
70 } else { | |
71 *dst = sample; | |
72 } | |
73 src += 2; | |
74 dst += 1; | |
75 } | |
76 } | |
77 break; | |
78 | |
79 case AUDIO_U16: { | |
80 Uint8 *src, *dst; | |
81 | |
82 src = cvt->buf; | |
83 dst = cvt->buf; | |
84 if ( (format & 0x1000) == 0x1000 ) { | |
85 for ( i=cvt->len_cvt/4; i; --i ) { | |
86 sample = (Uint16)((src[0]<<8)|src[1])+ | |
87 (Uint16)((src[2]<<8)|src[3]); | |
88 if ( sample > 65535 ) { | |
89 dst[0] = 0xFF; | |
90 dst[1] = 0xFF; | |
91 } else { | |
92 dst[1] = (sample&0xFF); | |
93 sample >>= 8; | |
94 dst[0] = (sample&0xFF); | |
95 } | |
96 src += 4; | |
97 dst += 2; | |
98 } | |
99 } else { | |
100 for ( i=cvt->len_cvt/4; i; --i ) { | |
101 sample = (Uint16)((src[1]<<8)|src[0])+ | |
102 (Uint16)((src[3]<<8)|src[2]); | |
103 if ( sample > 65535 ) { | |
104 dst[0] = 0xFF; | |
105 dst[1] = 0xFF; | |
106 } else { | |
107 dst[0] = (sample&0xFF); | |
108 sample >>= 8; | |
109 dst[1] = (sample&0xFF); | |
110 } | |
111 src += 4; | |
112 dst += 2; | |
113 } | |
114 } | |
115 } | |
116 break; | |
117 | |
118 case AUDIO_S16: { | |
119 Uint8 *src, *dst; | |
120 | |
121 src = cvt->buf; | |
122 dst = cvt->buf; | |
123 if ( (format & 0x1000) == 0x1000 ) { | |
124 for ( i=cvt->len_cvt/4; i; --i ) { | |
125 sample = (Sint16)((src[0]<<8)|src[1])+ | |
126 (Sint16)((src[2]<<8)|src[3]); | |
127 if ( sample > 32767 ) { | |
128 dst[0] = 0x7F; | |
129 dst[1] = 0xFF; | |
130 } else | |
131 if ( sample < -32768 ) { | |
132 dst[0] = 0x80; | |
133 dst[1] = 0x00; | |
134 } else { | |
135 dst[1] = (sample&0xFF); | |
136 sample >>= 8; | |
137 dst[0] = (sample&0xFF); | |
138 } | |
139 src += 4; | |
140 dst += 2; | |
141 } | |
142 } else { | |
143 for ( i=cvt->len_cvt/4; i; --i ) { | |
144 sample = (Sint16)((src[1]<<8)|src[0])+ | |
145 (Sint16)((src[3]<<8)|src[2]); | |
146 if ( sample > 32767 ) { | |
147 dst[1] = 0x7F; | |
148 dst[0] = 0xFF; | |
149 } else | |
150 if ( sample < -32768 ) { | |
151 dst[1] = 0x80; | |
152 dst[0] = 0x00; | |
153 } else { | |
154 dst[0] = (sample&0xFF); | |
155 sample >>= 8; | |
156 dst[1] = (sample&0xFF); | |
157 } | |
158 src += 4; | |
159 dst += 2; | |
160 } | |
161 } | |
162 } | |
163 break; | |
164 } | |
165 cvt->len_cvt /= 2; | |
166 if ( cvt->filters[++cvt->filter_index] ) { | |
167 cvt->filters[cvt->filter_index](cvt, format); | |
168 } | |
169 } | |
170 | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
171 /* Discard top 4 channels */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
172 void SDL_ConvertStrip(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
173 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
174 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
175 Sint32 lsample, rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
176 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
177 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
178 fprintf(stderr, "Converting down to stereo\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
179 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
180 switch (format&0x8018) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
181 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
182 case AUDIO_U8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
183 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
184 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
185 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
186 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
187 for ( i=cvt->len_cvt/6; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
188 lsample = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
189 rsample = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
190 dst[0] = lsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
191 dst[1] = rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
192 src += 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
193 dst += 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
194 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
195 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
196 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
197 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
198 case AUDIO_S8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
199 Sint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
200 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
201 src = (Sint8 *)cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
202 dst = (Sint8 *)cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
203 for ( i=cvt->len_cvt/6; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
204 lsample = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
205 rsample = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
206 dst[0] = lsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
207 dst[1] = rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
208 src += 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
209 dst += 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
210 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
211 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
212 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
213 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
214 case AUDIO_U16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
215 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
216 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
217 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
218 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
219 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
220 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
221 lsample = (Uint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
222 rsample = (Uint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
223 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
224 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
225 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
226 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
227 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
228 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
229 src += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
230 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
231 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
232 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
233 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
234 lsample = (Uint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
235 rsample = (Uint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
236 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
237 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
238 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
239 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
240 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
241 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
242 src += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
243 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
244 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
245 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
246 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
247 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
248 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
249 case AUDIO_S16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
250 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
251 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
252 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
253 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
254 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
255 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
256 lsample = (Sint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
257 rsample = (Sint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
258 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
259 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
260 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
261 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
262 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
263 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
264 src += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
265 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
266 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
267 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
268 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
269 lsample = (Sint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
270 rsample = (Sint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
271 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
272 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
273 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
274 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
275 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
276 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
277 src += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
278 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
279 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
280 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
281 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
282 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
283 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
284 cvt->len_cvt /= 3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
285 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
286 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
287 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
288 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
289 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
290 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
291 /* Discard top 2 channels of 6 */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
292 void SDL_ConvertStrip_2(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
293 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
294 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
295 Sint32 lsample, rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
296 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
297 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
298 fprintf(stderr, "Converting 6 down to quad\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
299 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
300 switch (format&0x8018) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
301 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
302 case AUDIO_U8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
303 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
304 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
305 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
306 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
307 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
308 lsample = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
309 rsample = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
310 dst[0] = lsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
311 dst[1] = rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
312 src += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
313 dst += 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
314 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
315 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
316 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
317 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
318 case AUDIO_S8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
319 Sint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
320 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
321 src = (Sint8 *)cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
322 dst = (Sint8 *)cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
323 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
324 lsample = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
325 rsample = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
326 dst[0] = lsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
327 dst[1] = rsample; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
328 src += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
329 dst += 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
330 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
331 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
332 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
333 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
334 case AUDIO_U16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
335 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
336 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
337 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
338 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
339 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
340 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
341 lsample = (Uint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
342 rsample = (Uint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
343 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
344 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
345 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
346 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
347 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
348 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
349 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
350 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
351 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
352 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
353 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
354 lsample = (Uint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
355 rsample = (Uint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
356 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
357 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
358 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
359 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
360 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
361 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
362 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
363 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
364 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
365 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
366 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
367 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
368 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
369 case AUDIO_S16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
370 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
371 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
372 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
373 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
374 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
375 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
376 lsample = (Sint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
377 rsample = (Sint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
378 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
379 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
380 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
381 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
382 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
383 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
384 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
385 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
386 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
387 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
388 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
389 lsample = (Sint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
390 rsample = (Sint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
391 dst[0] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
392 lsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
393 dst[1] = (lsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
394 dst[2] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
395 rsample >>= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
396 dst[3] = (rsample&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
397 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
398 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
399 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
400 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
401 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
402 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
403 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
404 cvt->len_cvt /= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
405 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
406 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
407 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
408 } |
0 | 409 |
410 /* Duplicate a mono channel to both stereo channels */ | |
411 void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format) | |
412 { | |
413 int i; | |
414 | |
415 #ifdef DEBUG_CONVERT | |
416 fprintf(stderr, "Converting to stereo\n"); | |
417 #endif | |
418 if ( (format & 0xFF) == 16 ) { | |
419 Uint16 *src, *dst; | |
420 | |
421 src = (Uint16 *)(cvt->buf+cvt->len_cvt); | |
422 dst = (Uint16 *)(cvt->buf+cvt->len_cvt*2); | |
423 for ( i=cvt->len_cvt/2; i; --i ) { | |
424 dst -= 2; | |
425 src -= 1; | |
426 dst[0] = src[0]; | |
427 dst[1] = src[0]; | |
428 } | |
429 } else { | |
430 Uint8 *src, *dst; | |
431 | |
432 src = cvt->buf+cvt->len_cvt; | |
433 dst = cvt->buf+cvt->len_cvt*2; | |
434 for ( i=cvt->len_cvt; i; --i ) { | |
435 dst -= 2; | |
436 src -= 1; | |
437 dst[0] = src[0]; | |
438 dst[1] = src[0]; | |
439 } | |
440 } | |
441 cvt->len_cvt *= 2; | |
442 if ( cvt->filters[++cvt->filter_index] ) { | |
443 cvt->filters[cvt->filter_index](cvt, format); | |
444 } | |
445 } | |
446 | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
447 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
448 /* Duplicate a stereo channel to a pseudo-5.1 stream */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
449 void SDL_ConvertSurround(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
450 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
451 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
452 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
453 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
454 fprintf(stderr, "Converting stereo to surround\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
455 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
456 switch (format&0x8018) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
457 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
458 case AUDIO_U8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
459 Uint8 *src, *dst, lf, rf, ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
460 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
461 src = (Uint8 *)(cvt->buf+cvt->len_cvt); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
462 dst = (Uint8 *)(cvt->buf+cvt->len_cvt*3); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
463 for ( i=cvt->len_cvt; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
464 dst -= 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
465 src -= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
466 lf = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
467 rf = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
468 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
469 dst[0] = lf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
470 dst[1] = rf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
471 dst[2] = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
472 dst[3] = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
473 dst[4] = ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
474 dst[5] = ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
475 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
476 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
477 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
478 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
479 case AUDIO_S8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
480 Sint8 *src, *dst, lf, rf, ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
481 |
1011
4095d9ca23f2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
942
diff
changeset
|
482 src = (Sint8 *)cvt->buf+cvt->len_cvt; |
4095d9ca23f2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
942
diff
changeset
|
483 dst = (Sint8 *)cvt->buf+cvt->len_cvt*3; |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
484 for ( i=cvt->len_cvt; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
485 dst -= 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
486 src -= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
487 lf = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
488 rf = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
489 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
490 dst[0] = lf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
491 dst[1] = rf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
492 dst[2] = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
493 dst[3] = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
494 dst[4] = ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
495 dst[5] = ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
496 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
497 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
498 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
499 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
500 case AUDIO_U16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
501 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
502 Uint16 lf, rf, ce, lr, rr; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
503 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
504 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
505 dst = cvt->buf+cvt->len_cvt*3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
506 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
507 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
508 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
509 dst -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
510 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
511 lf = (Uint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
512 rf = (Uint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
513 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
514 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
515 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
516 dst[1] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
517 dst[0] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
518 dst[3] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
519 dst[2] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
520 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
521 dst[1+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
522 dst[0+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
523 dst[3+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
524 dst[2+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
525 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
526 dst[1+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
527 dst[0+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
528 dst[3+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
529 dst[2+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
530 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
531 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
532 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
533 dst -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
534 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
535 lf = (Uint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
536 rf = (Uint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
537 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
538 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
539 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
540 dst[0] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
541 dst[1] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
542 dst[2] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
543 dst[3] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
544 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
545 dst[0+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
546 dst[1+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
547 dst[2+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
548 dst[3+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
549 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
550 dst[0+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
551 dst[1+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
552 dst[2+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
553 dst[3+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
554 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
555 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
556 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
557 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
558 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
559 case AUDIO_S16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
560 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
561 Sint16 lf, rf, ce, lr, rr; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
562 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
563 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
564 dst = cvt->buf+cvt->len_cvt*3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
565 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
566 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
567 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
568 dst -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
569 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
570 lf = (Sint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
571 rf = (Sint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
572 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
573 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
574 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
575 dst[1] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
576 dst[0] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
577 dst[3] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
578 dst[2] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
579 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
580 dst[1+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
581 dst[0+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
582 dst[3+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
583 dst[2+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
584 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
585 dst[1+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
586 dst[0+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
587 dst[3+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
588 dst[2+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
589 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
590 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
591 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
592 dst -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
593 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
594 lf = (Sint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
595 rf = (Sint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
596 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
597 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
598 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
599 dst[0] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
600 dst[1] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
601 dst[2] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
602 dst[3] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
603 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
604 dst[0+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
605 dst[1+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
606 dst[2+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
607 dst[3+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
608 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
609 dst[0+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
610 dst[1+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
611 dst[2+8] = (ce&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
612 dst[3+8] = ((ce>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
613 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
614 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
615 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
616 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
617 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
618 cvt->len_cvt *= 3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
619 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
620 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
621 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
622 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
623 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
624 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
625 /* Duplicate a stereo channel to a pseudo-4.0 stream */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
626 void SDL_ConvertSurround_4(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
627 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
628 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
629 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
630 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
631 fprintf(stderr, "Converting stereo to quad\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
632 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
633 switch (format&0x8018) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
634 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
635 case AUDIO_U8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
636 Uint8 *src, *dst, lf, rf, ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
637 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
638 src = (Uint8 *)(cvt->buf+cvt->len_cvt); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
639 dst = (Uint8 *)(cvt->buf+cvt->len_cvt*2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
640 for ( i=cvt->len_cvt; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
641 dst -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
642 src -= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
643 lf = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
644 rf = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
645 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
646 dst[0] = lf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
647 dst[1] = rf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
648 dst[2] = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
649 dst[3] = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
650 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
651 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
652 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
653 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
654 case AUDIO_S8: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
655 Sint8 *src, *dst, lf, rf, ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
656 |
1011
4095d9ca23f2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
942
diff
changeset
|
657 src = (Sint8 *)cvt->buf+cvt->len_cvt; |
4095d9ca23f2
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
942
diff
changeset
|
658 dst = (Sint8 *)cvt->buf+cvt->len_cvt*2; |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
659 for ( i=cvt->len_cvt; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
660 dst -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
661 src -= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
662 lf = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
663 rf = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
664 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
665 dst[0] = lf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
666 dst[1] = rf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
667 dst[2] = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
668 dst[3] = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
669 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
670 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
671 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
672 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
673 case AUDIO_U16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
674 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
675 Uint16 lf, rf, ce, lr, rr; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
676 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
677 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
678 dst = cvt->buf+cvt->len_cvt*2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
679 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
680 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
681 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
682 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
683 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
684 lf = (Uint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
685 rf = (Uint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
686 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
687 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
688 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
689 dst[1] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
690 dst[0] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
691 dst[3] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
692 dst[2] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
693 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
694 dst[1+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
695 dst[0+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
696 dst[3+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
697 dst[2+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
698 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
699 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
700 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
701 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
702 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
703 lf = (Uint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
704 rf = (Uint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
705 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
706 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
707 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
708 dst[0] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
709 dst[1] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
710 dst[2] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
711 dst[3] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
712 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
713 dst[0+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
714 dst[1+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
715 dst[2+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
716 dst[3+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
717 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
718 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
719 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
720 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
721 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
722 case AUDIO_S16: { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
723 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
724 Sint16 lf, rf, ce, lr, rr; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
725 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
726 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
727 dst = cvt->buf+cvt->len_cvt*2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
728 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
729 if ( (format & 0x1000) == 0x1000 ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
730 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
731 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
732 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
733 lf = (Sint16)((src[0]<<8)|src[1]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
734 rf = (Sint16)((src[2]<<8)|src[3]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
735 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
736 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
737 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
738 dst[1] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
739 dst[0] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
740 dst[3] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
741 dst[2] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
742 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
743 dst[1+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
744 dst[0+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
745 dst[3+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
746 dst[2+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
747 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
748 } else { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
749 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
750 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
751 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
752 lf = (Sint16)((src[1]<<8)|src[0]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
753 rf = (Sint16)((src[3]<<8)|src[2]); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
754 ce = (lf/2) + (rf/2); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
755 rr = lf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
756 lr = rf - ce; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
757 dst[0] = (lf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
758 dst[1] = ((lf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
759 dst[2] = (rf&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
760 dst[3] = ((rf>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
761 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
762 dst[0+4] = (lr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
763 dst[1+4] = ((lr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
764 dst[2+4] = (rr&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
765 dst[3+4] = ((rr>>8)&0xFF); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
766 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
767 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
768 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
769 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
770 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
771 cvt->len_cvt *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
772 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
773 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
774 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
775 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
776 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
777 |
0 | 778 /* Convert 8-bit to 16-bit - LSB */ |
779 void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format) | |
780 { | |
781 int i; | |
782 Uint8 *src, *dst; | |
783 | |
784 #ifdef DEBUG_CONVERT | |
785 fprintf(stderr, "Converting to 16-bit LSB\n"); | |
786 #endif | |
787 src = cvt->buf+cvt->len_cvt; | |
788 dst = cvt->buf+cvt->len_cvt*2; | |
789 for ( i=cvt->len_cvt; i; --i ) { | |
790 src -= 1; | |
791 dst -= 2; | |
792 dst[1] = *src; | |
793 dst[0] = 0; | |
794 } | |
795 format = ((format & ~0x0008) | AUDIO_U16LSB); | |
796 cvt->len_cvt *= 2; | |
797 if ( cvt->filters[++cvt->filter_index] ) { | |
798 cvt->filters[cvt->filter_index](cvt, format); | |
799 } | |
800 } | |
801 /* Convert 8-bit to 16-bit - MSB */ | |
802 void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format) | |
803 { | |
804 int i; | |
805 Uint8 *src, *dst; | |
806 | |
807 #ifdef DEBUG_CONVERT | |
808 fprintf(stderr, "Converting to 16-bit MSB\n"); | |
809 #endif | |
810 src = cvt->buf+cvt->len_cvt; | |
811 dst = cvt->buf+cvt->len_cvt*2; | |
812 for ( i=cvt->len_cvt; i; --i ) { | |
813 src -= 1; | |
814 dst -= 2; | |
815 dst[0] = *src; | |
816 dst[1] = 0; | |
817 } | |
818 format = ((format & ~0x0008) | AUDIO_U16MSB); | |
819 cvt->len_cvt *= 2; | |
820 if ( cvt->filters[++cvt->filter_index] ) { | |
821 cvt->filters[cvt->filter_index](cvt, format); | |
822 } | |
823 } | |
824 | |
825 /* Convert 16-bit to 8-bit */ | |
826 void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format) | |
827 { | |
828 int i; | |
829 Uint8 *src, *dst; | |
830 | |
831 #ifdef DEBUG_CONVERT | |
832 fprintf(stderr, "Converting to 8-bit\n"); | |
833 #endif | |
834 src = cvt->buf; | |
835 dst = cvt->buf; | |
836 if ( (format & 0x1000) != 0x1000 ) { /* Little endian */ | |
837 ++src; | |
838 } | |
839 for ( i=cvt->len_cvt/2; i; --i ) { | |
840 *dst = *src; | |
841 src += 2; | |
842 dst += 1; | |
843 } | |
844 format = ((format & ~0x9010) | AUDIO_U8); | |
845 cvt->len_cvt /= 2; | |
846 if ( cvt->filters[++cvt->filter_index] ) { | |
847 cvt->filters[cvt->filter_index](cvt, format); | |
848 } | |
849 } | |
850 | |
851 /* Toggle signed/unsigned */ | |
852 void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format) | |
853 { | |
854 int i; | |
855 Uint8 *data; | |
856 | |
857 #ifdef DEBUG_CONVERT | |
858 fprintf(stderr, "Converting audio signedness\n"); | |
859 #endif | |
860 data = cvt->buf; | |
861 if ( (format & 0xFF) == 16 ) { | |
862 if ( (format & 0x1000) != 0x1000 ) { /* Little endian */ | |
863 ++data; | |
864 } | |
865 for ( i=cvt->len_cvt/2; i; --i ) { | |
866 *data ^= 0x80; | |
867 data += 2; | |
868 } | |
869 } else { | |
870 for ( i=cvt->len_cvt; i; --i ) { | |
871 *data++ ^= 0x80; | |
872 } | |
873 } | |
874 format = (format ^ 0x8000); | |
875 if ( cvt->filters[++cvt->filter_index] ) { | |
876 cvt->filters[cvt->filter_index](cvt, format); | |
877 } | |
878 } | |
879 | |
880 /* Toggle endianness */ | |
881 void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format) | |
882 { | |
883 int i; | |
884 Uint8 *data, tmp; | |
885 | |
886 #ifdef DEBUG_CONVERT | |
887 fprintf(stderr, "Converting audio endianness\n"); | |
888 #endif | |
889 data = cvt->buf; | |
890 for ( i=cvt->len_cvt/2; i; --i ) { | |
891 tmp = data[0]; | |
892 data[0] = data[1]; | |
893 data[1] = tmp; | |
894 data += 2; | |
895 } | |
896 format = (format ^ 0x1000); | |
897 if ( cvt->filters[++cvt->filter_index] ) { | |
898 cvt->filters[cvt->filter_index](cvt, format); | |
899 } | |
900 } | |
901 | |
902 /* Convert rate up by multiple of 2 */ | |
903 void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format) | |
904 { | |
905 int i; | |
906 Uint8 *src, *dst; | |
907 | |
908 #ifdef DEBUG_CONVERT | |
909 fprintf(stderr, "Converting audio rate * 2\n"); | |
910 #endif | |
911 src = cvt->buf+cvt->len_cvt; | |
912 dst = cvt->buf+cvt->len_cvt*2; | |
913 switch (format & 0xFF) { | |
914 case 8: | |
915 for ( i=cvt->len_cvt; i; --i ) { | |
916 src -= 1; | |
917 dst -= 2; | |
918 dst[0] = src[0]; | |
919 dst[1] = src[0]; | |
920 } | |
921 break; | |
922 case 16: | |
923 for ( i=cvt->len_cvt/2; i; --i ) { | |
924 src -= 2; | |
925 dst -= 4; | |
926 dst[0] = src[0]; | |
927 dst[1] = src[1]; | |
928 dst[2] = src[0]; | |
929 dst[3] = src[1]; | |
930 } | |
931 break; | |
932 } | |
933 cvt->len_cvt *= 2; | |
934 if ( cvt->filters[++cvt->filter_index] ) { | |
935 cvt->filters[cvt->filter_index](cvt, format); | |
936 } | |
937 } | |
938 | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
939 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
940 /* Convert rate up by multiple of 2, for stereo */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
941 void SDL_RateMUL2_c2(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
942 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
943 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
944 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
945 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
946 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
947 fprintf(stderr, "Converting audio rate * 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
948 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
949 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
950 dst = cvt->buf+cvt->len_cvt*2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
951 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
952 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
953 for ( i=cvt->len_cvt/2; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
954 src -= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
955 dst -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
956 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
957 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
958 dst[2] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
959 dst[3] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
960 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
961 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
962 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
963 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
964 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
965 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
966 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
967 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
968 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
969 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
970 dst[4] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
971 dst[5] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
972 dst[6] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
973 dst[7] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
974 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
975 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
976 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
977 cvt->len_cvt *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
978 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
979 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
980 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
981 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
982 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
983 /* Convert rate up by multiple of 2, for quad */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
984 void SDL_RateMUL2_c4(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
985 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
986 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
987 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
988 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
989 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
990 fprintf(stderr, "Converting audio rate * 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
991 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
992 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
993 dst = cvt->buf+cvt->len_cvt*2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
994 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
995 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
996 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
997 src -= 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
998 dst -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
999 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1000 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1001 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1002 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1003 dst[4] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1004 dst[5] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1005 dst[6] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1006 dst[7] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1007 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1008 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1009 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1010 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1011 src -= 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1012 dst -= 16; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1013 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1014 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1015 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1016 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1017 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1018 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1019 dst[6] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1020 dst[7] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1021 dst[8] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1022 dst[9] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1023 dst[10] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1024 dst[11] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1025 dst[12] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1026 dst[13] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1027 dst[14] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1028 dst[15] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1029 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1030 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1031 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1032 cvt->len_cvt *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1033 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1034 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1035 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1036 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1037 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1038 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1039 /* Convert rate up by multiple of 2, for 5.1 */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1040 void SDL_RateMUL2_c6(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1041 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1042 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1043 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1044 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1045 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1046 fprintf(stderr, "Converting audio rate * 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1047 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1048 src = cvt->buf+cvt->len_cvt; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1049 dst = cvt->buf+cvt->len_cvt*2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1050 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1051 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1052 for ( i=cvt->len_cvt/6; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1053 src -= 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1054 dst -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1055 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1056 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1057 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1058 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1059 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1060 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1061 dst[6] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1062 dst[7] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1063 dst[8] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1064 dst[9] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1065 dst[10] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1066 dst[11] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1067 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1068 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1069 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1070 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1071 src -= 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1072 dst -= 24; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1073 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1074 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1075 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1076 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1077 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1078 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1079 dst[6] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1080 dst[7] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1081 dst[8] = src[8]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1082 dst[9] = src[9]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1083 dst[10] = src[10]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1084 dst[11] = src[11]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1085 dst[12] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1086 dst[13] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1087 dst[14] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1088 dst[15] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1089 dst[16] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1090 dst[17] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1091 dst[18] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1092 dst[19] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1093 dst[20] = src[8]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1094 dst[21] = src[9]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1095 dst[22] = src[10]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1096 dst[23] = src[11]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1097 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1098 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1099 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1100 cvt->len_cvt *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1101 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1102 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1103 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1104 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1105 |
0 | 1106 /* Convert rate down by multiple of 2 */ |
1107 void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format) | |
1108 { | |
1109 int i; | |
1110 Uint8 *src, *dst; | |
1111 | |
1112 #ifdef DEBUG_CONVERT | |
1113 fprintf(stderr, "Converting audio rate / 2\n"); | |
1114 #endif | |
1115 src = cvt->buf; | |
1116 dst = cvt->buf; | |
1117 switch (format & 0xFF) { | |
1118 case 8: | |
1119 for ( i=cvt->len_cvt/2; i; --i ) { | |
1120 dst[0] = src[0]; | |
1121 src += 2; | |
1122 dst += 1; | |
1123 } | |
1124 break; | |
1125 case 16: | |
1126 for ( i=cvt->len_cvt/4; i; --i ) { | |
1127 dst[0] = src[0]; | |
1128 dst[1] = src[1]; | |
1129 src += 4; | |
1130 dst += 2; | |
1131 } | |
1132 break; | |
1133 } | |
1134 cvt->len_cvt /= 2; | |
1135 if ( cvt->filters[++cvt->filter_index] ) { | |
1136 cvt->filters[cvt->filter_index](cvt, format); | |
1137 } | |
1138 } | |
1139 | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1140 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1141 /* Convert rate down by multiple of 2, for stereo */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1142 void SDL_RateDIV2_c2(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1143 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1144 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1145 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1146 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1147 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1148 fprintf(stderr, "Converting audio rate / 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1149 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1150 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1151 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1152 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1153 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1154 for ( i=cvt->len_cvt/4; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1155 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1156 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1157 src += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1158 dst += 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1159 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1160 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1161 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1162 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1163 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1164 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1165 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1166 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1167 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1168 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1169 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1170 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1171 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1172 cvt->len_cvt /= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1173 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1174 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1175 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1176 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1177 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1178 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1179 /* Convert rate down by multiple of 2, for quad */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1180 void SDL_RateDIV2_c4(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1181 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1182 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1183 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1184 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1185 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1186 fprintf(stderr, "Converting audio rate / 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1187 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1188 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1189 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1190 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1191 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1192 for ( i=cvt->len_cvt/8; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1193 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1194 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1195 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1196 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1197 src += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1198 dst += 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1199 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1200 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1201 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1202 for ( i=cvt->len_cvt/16; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1203 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1204 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1205 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1206 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1207 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1208 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1209 dst[6] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1210 dst[7] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1211 src += 16; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1212 dst += 8; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1213 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1214 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1215 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1216 cvt->len_cvt /= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1217 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1218 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1219 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1220 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1221 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1222 /* Convert rate down by multiple of 2, for 5.1 */ |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1223 void SDL_RateDIV2_c6(SDL_AudioCVT *cvt, Uint16 format) |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1224 { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1225 int i; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1226 Uint8 *src, *dst; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1227 |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1228 #ifdef DEBUG_CONVERT |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1229 fprintf(stderr, "Converting audio rate / 2\n"); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1230 #endif |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1231 src = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1232 dst = cvt->buf; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1233 switch (format & 0xFF) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1234 case 8: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1235 for ( i=cvt->len_cvt/12; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1236 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1237 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1238 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1239 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1240 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1241 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1242 src += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1243 dst += 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1244 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1245 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1246 case 16: |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1247 for ( i=cvt->len_cvt/24; i; --i ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1248 dst[0] = src[0]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1249 dst[1] = src[1]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1250 dst[2] = src[2]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1251 dst[3] = src[3]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1252 dst[4] = src[4]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1253 dst[5] = src[5]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1254 dst[6] = src[6]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1255 dst[7] = src[7]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1256 dst[8] = src[8]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1257 dst[9] = src[9]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1258 dst[10] = src[10]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1259 dst[11] = src[11]; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1260 src += 24; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1261 dst += 12; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1262 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1263 break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1264 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1265 cvt->len_cvt /= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1266 if ( cvt->filters[++cvt->filter_index] ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1267 cvt->filters[cvt->filter_index](cvt, format); |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1268 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1269 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1270 |
0 | 1271 /* Very slow rate conversion routine */ |
1272 void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format) | |
1273 { | |
1274 double ipos; | |
1275 int i, clen; | |
1276 | |
1277 #ifdef DEBUG_CONVERT | |
1278 fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0/cvt->rate_incr); | |
1279 #endif | |
1280 clen = (int)((double)cvt->len_cvt / cvt->rate_incr); | |
1281 if ( cvt->rate_incr > 1.0 ) { | |
1282 switch (format & 0xFF) { | |
1283 case 8: { | |
1284 Uint8 *output; | |
1285 | |
1286 output = cvt->buf; | |
1287 ipos = 0.0; | |
1288 for ( i=clen; i; --i ) { | |
1289 *output = cvt->buf[(int)ipos]; | |
1290 ipos += cvt->rate_incr; | |
1291 output += 1; | |
1292 } | |
1293 } | |
1294 break; | |
1295 | |
1296 case 16: { | |
1297 Uint16 *output; | |
1298 | |
1299 clen &= ~1; | |
1300 output = (Uint16 *)cvt->buf; | |
1301 ipos = 0.0; | |
1302 for ( i=clen/2; i; --i ) { | |
1303 *output=((Uint16 *)cvt->buf)[(int)ipos]; | |
1304 ipos += cvt->rate_incr; | |
1305 output += 1; | |
1306 } | |
1307 } | |
1308 break; | |
1309 } | |
1310 } else { | |
1311 switch (format & 0xFF) { | |
1312 case 8: { | |
1313 Uint8 *output; | |
1314 | |
1315 output = cvt->buf+clen; | |
1316 ipos = (double)cvt->len_cvt; | |
1317 for ( i=clen; i; --i ) { | |
1318 ipos -= cvt->rate_incr; | |
1319 output -= 1; | |
1320 *output = cvt->buf[(int)ipos]; | |
1321 } | |
1322 } | |
1323 break; | |
1324 | |
1325 case 16: { | |
1326 Uint16 *output; | |
1327 | |
1328 clen &= ~1; | |
1329 output = (Uint16 *)(cvt->buf+clen); | |
1330 ipos = (double)cvt->len_cvt/2; | |
1331 for ( i=clen/2; i; --i ) { | |
1332 ipos -= cvt->rate_incr; | |
1333 output -= 1; | |
1334 *output=((Uint16 *)cvt->buf)[(int)ipos]; | |
1335 } | |
1336 } | |
1337 break; | |
1338 } | |
1339 } | |
1340 cvt->len_cvt = clen; | |
1341 if ( cvt->filters[++cvt->filter_index] ) { | |
1342 cvt->filters[cvt->filter_index](cvt, format); | |
1343 } | |
1344 } | |
1345 | |
1346 int SDL_ConvertAudio(SDL_AudioCVT *cvt) | |
1347 { | |
1348 /* Make sure there's data to convert */ | |
1349 if ( cvt->buf == NULL ) { | |
1350 SDL_SetError("No buffer allocated for conversion"); | |
1351 return(-1); | |
1352 } | |
1353 /* Return okay if no conversion is necessary */ | |
1354 cvt->len_cvt = cvt->len; | |
1355 if ( cvt->filters[0] == NULL ) { | |
1356 return(0); | |
1357 } | |
1358 | |
1359 /* Set up the conversion and go! */ | |
1360 cvt->filter_index = 0; | |
1361 cvt->filters[0](cvt, cvt->src_format); | |
1362 return(0); | |
1363 } | |
1364 | |
1365 /* Creates a set of audio filters to convert from one format to another. | |
1366 Returns -1 if the format conversion is not supported, or 1 if the | |
1367 audio filter is set up. | |
1368 */ | |
1369 | |
1370 int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, | |
1371 Uint16 src_format, Uint8 src_channels, int src_rate, | |
1372 Uint16 dst_format, Uint8 dst_channels, int dst_rate) | |
1373 { | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1374 /*printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n", |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1375 src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);*/ |
0 | 1376 /* Start off with no conversion necessary */ |
1377 cvt->needed = 0; | |
1378 cvt->filter_index = 0; | |
1379 cvt->filters[0] = NULL; | |
1380 cvt->len_mult = 1; | |
1381 cvt->len_ratio = 1.0; | |
1382 | |
1383 /* First filter: Endian conversion from src to dst */ | |
1384 if ( (src_format & 0x1000) != (dst_format & 0x1000) | |
1385 && ((src_format & 0xff) != 8) ) { | |
1386 cvt->filters[cvt->filter_index++] = SDL_ConvertEndian; | |
1387 } | |
1388 | |
1389 /* Second filter: Sign conversion -- signed/unsigned */ | |
1390 if ( (src_format & 0x8000) != (dst_format & 0x8000) ) { | |
1391 cvt->filters[cvt->filter_index++] = SDL_ConvertSign; | |
1392 } | |
1393 | |
1394 /* Next filter: Convert 16 bit <--> 8 bit PCM */ | |
1395 if ( (src_format & 0xFF) != (dst_format & 0xFF) ) { | |
1396 switch (dst_format&0x10FF) { | |
1397 case AUDIO_U8: | |
1398 cvt->filters[cvt->filter_index++] = | |
1399 SDL_Convert8; | |
1400 cvt->len_ratio /= 2; | |
1401 break; | |
1402 case AUDIO_U16LSB: | |
1403 cvt->filters[cvt->filter_index++] = | |
1404 SDL_Convert16LSB; | |
1405 cvt->len_mult *= 2; | |
1406 cvt->len_ratio *= 2; | |
1407 break; | |
1408 case AUDIO_U16MSB: | |
1409 cvt->filters[cvt->filter_index++] = | |
1410 SDL_Convert16MSB; | |
1411 cvt->len_mult *= 2; | |
1412 cvt->len_ratio *= 2; | |
1413 break; | |
1414 } | |
1415 } | |
1416 | |
1417 /* Last filter: Mono/Stereo conversion */ | |
1418 if ( src_channels != dst_channels ) { | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1419 if ( (src_channels == 1) && (dst_channels > 1) ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1420 cvt->filters[cvt->filter_index++] = |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1421 SDL_ConvertStereo; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1422 cvt->len_mult *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1423 src_channels = 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1424 cvt->len_ratio *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1425 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1426 if ( (src_channels == 2) && |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1427 (dst_channels == 6) ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1428 cvt->filters[cvt->filter_index++] = |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1429 SDL_ConvertSurround; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1430 src_channels = 6; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1431 cvt->len_mult *= 3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1432 cvt->len_ratio *= 3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1433 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1434 if ( (src_channels == 2) && |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1435 (dst_channels == 4) ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1436 cvt->filters[cvt->filter_index++] = |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1437 SDL_ConvertSurround_4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1438 src_channels = 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1439 cvt->len_mult *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1440 cvt->len_ratio *= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1441 } |
0 | 1442 while ( (src_channels*2) <= dst_channels ) { |
1443 cvt->filters[cvt->filter_index++] = | |
1444 SDL_ConvertStereo; | |
1445 cvt->len_mult *= 2; | |
1446 src_channels *= 2; | |
1447 cvt->len_ratio *= 2; | |
1448 } | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1449 if ( (src_channels == 6) && |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1450 (dst_channels <= 2) ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1451 cvt->filters[cvt->filter_index++] = |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1452 SDL_ConvertStrip; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1453 src_channels = 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1454 cvt->len_ratio /= 3; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1455 } |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1456 if ( (src_channels == 6) && |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1457 (dst_channels == 4) ) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1458 cvt->filters[cvt->filter_index++] = |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1459 SDL_ConvertStrip_2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1460 src_channels = 4; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1461 cvt->len_ratio /= 2; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1462 } |
0 | 1463 /* This assumes that 4 channel audio is in the format: |
1464 Left {front/back} + Right {front/back} | |
1465 so converting to L/R stereo works properly. | |
1466 */ | |
1467 while ( ((src_channels%2) == 0) && | |
1468 ((src_channels/2) >= dst_channels) ) { | |
1469 cvt->filters[cvt->filter_index++] = | |
1470 SDL_ConvertMono; | |
1471 src_channels /= 2; | |
1472 cvt->len_ratio /= 2; | |
1473 } | |
1474 if ( src_channels != dst_channels ) { | |
1475 /* Uh oh.. */; | |
1476 } | |
1477 } | |
1478 | |
1479 /* Do rate conversion */ | |
1480 cvt->rate_incr = 0.0; | |
1481 if ( (src_rate/100) != (dst_rate/100) ) { | |
1482 Uint32 hi_rate, lo_rate; | |
1483 int len_mult; | |
1484 double len_ratio; | |
1485 void (*rate_cvt)(SDL_AudioCVT *cvt, Uint16 format); | |
1486 | |
1487 if ( src_rate > dst_rate ) { | |
1488 hi_rate = src_rate; | |
1489 lo_rate = dst_rate; | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1490 switch (src_channels) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1491 case 1: rate_cvt = SDL_RateDIV2; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1492 case 2: rate_cvt = SDL_RateDIV2_c2; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1493 case 4: rate_cvt = SDL_RateDIV2_c4; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1494 case 6: rate_cvt = SDL_RateDIV2_c6; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1495 default: return -1; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1496 } |
0 | 1497 len_mult = 1; |
1498 len_ratio = 0.5; | |
1499 } else { | |
1500 hi_rate = dst_rate; | |
1501 lo_rate = src_rate; | |
942
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1502 switch (src_channels) { |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1503 case 1: rate_cvt = SDL_RateMUL2; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1504 case 2: rate_cvt = SDL_RateMUL2_c2; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1505 case 4: rate_cvt = SDL_RateMUL2_c4; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1506 case 6: rate_cvt = SDL_RateMUL2_c6; break; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1507 default: return -1; |
41a59de7f2ed
Here are patches for SDL12 and SDL_mixer for 4 or 6 channel
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
1508 } |
0 | 1509 len_mult = 2; |
1510 len_ratio = 2.0; | |
1511 } | |
1512 /* If hi_rate = lo_rate*2^x then conversion is easy */ | |
1513 while ( ((lo_rate*2)/100) <= (hi_rate/100) ) { | |
1514 cvt->filters[cvt->filter_index++] = rate_cvt; | |
1515 cvt->len_mult *= len_mult; | |
1516 lo_rate *= 2; | |
1517 cvt->len_ratio *= len_ratio; | |
1518 } | |
1519 /* We may need a slow conversion here to finish up */ | |
1520 if ( (lo_rate/100) != (hi_rate/100) ) { | |
1521 #if 1 | |
1522 /* The problem with this is that if the input buffer is | |
1523 say 1K, and the conversion rate is say 1.1, then the | |
1524 output buffer is 1.1K, which may not be an acceptable | |
1525 buffer size for the audio driver (not a power of 2) | |
1526 */ | |
1527 /* For now, punt and hope the rate distortion isn't great. | |
1528 */ | |
1529 #else | |
1530 if ( src_rate < dst_rate ) { | |
1531 cvt->rate_incr = (double)lo_rate/hi_rate; | |
1532 cvt->len_mult *= 2; | |
1533 cvt->len_ratio /= cvt->rate_incr; | |
1534 } else { | |
1535 cvt->rate_incr = (double)hi_rate/lo_rate; | |
1536 cvt->len_ratio *= cvt->rate_incr; | |
1537 } | |
1538 cvt->filters[cvt->filter_index++] = SDL_RateSLOW; | |
1539 #endif | |
1540 } | |
1541 } | |
1542 | |
1543 /* Set up the filter information */ | |
1544 if ( cvt->filter_index != 0 ) { | |
1545 cvt->needed = 1; | |
1546 cvt->src_format = src_format; | |
1547 cvt->dst_format = dst_format; | |
1548 cvt->len = 0; | |
1549 cvt->buf = NULL; | |
1550 cvt->filters[cvt->filter_index] = NULL; | |
1551 } | |
1552 return(cvt->needed); | |
1553 } |