2 * some code for sample mixing
5 * This work is licensed under the terms of MAME license.
6 * See COPYING file in the top-level directory.
9 #define MAXOUT (+32767)
10 #define MINOUT (-32768)
13 #define Limit(val, max,min) { \
14 if ( val > max ) val = max; \
15 else if ( val < min ) val = min; \
19 void mix_32_to_16l_stereo(short *dest, int *src, int count)
23 for (; count > 0; count--)
28 Limit( l, MAXOUT, MINOUT );
29 Limit( r, MAXOUT, MINOUT );
36 void mix_32_to_16_mono(short *dest, int *src, int count)
40 for (; count > 0; count--)
44 Limit( l, MAXOUT, MINOUT );
50 void mix_16h_to_32(int *dest_buf, short *mp3_buf, int count)
54 *dest_buf++ += *mp3_buf++ >> 1;
58 void mix_16h_to_32_s1(int *dest_buf, short *mp3_buf, int count)
63 *dest_buf++ += *mp3_buf++ >> 1;
64 *dest_buf++ += *mp3_buf++ >> 1;
69 void mix_16h_to_32_s2(int *dest_buf, short *mp3_buf, int count)
74 *dest_buf++ += *mp3_buf++ >> 1;
75 *dest_buf++ += *mp3_buf++ >> 1;