annotate src/audio/SDL_audiocvt.c @ 3900:ce3a2bd11305 SDL-1.2

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