1 // some code for sample mixing
2 // (c) Copyright 2006-2007, Grazvydas "notaz" Ignotas
4 #define MAXOUT (+32767)
5 #define MINOUT (-32768)
8 #define Limit(val, max,min) { \
9 if ( val > max ) val = max; \
10 else if ( val < min ) val = min; \
14 void mix_32_to_16l_stereo(short *dest, int *src, int count)
18 for (; count > 0; count--)
23 Limit( l, MAXOUT, MINOUT );
24 Limit( r, MAXOUT, MINOUT );
31 void mix_32_to_16_mono(short *dest, int *src, int count)
35 for (; count > 0; count--)
39 Limit( l, MAXOUT, MINOUT );
45 void mix_16h_to_32(int *dest_buf, short *mp3_buf, int count)
49 *dest_buf++ += *mp3_buf++ >> 1;
53 void mix_16h_to_32_s1(int *dest_buf, short *mp3_buf, int count)
58 *dest_buf++ += *mp3_buf++ >> 1;
59 *dest_buf++ += *mp3_buf++ >> 1;
64 void mix_16h_to_32_s2(int *dest_buf, short *mp3_buf, int count)
69 *dest_buf++ += *mp3_buf++ >> 1;
70 *dest_buf++ += *mp3_buf++ >> 1;