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