mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
PCM sound, refactored code940
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@27 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
7573607016
commit
4f265db776
28 changed files with 914 additions and 312 deletions
57
Pico/sound/mix.c
Normal file
57
Pico/sound/mix.c
Normal file
|
@ -0,0 +1,57 @@
|
|||
#define MAXOUT (+32767)
|
||||
#define MINOUT (-32768)
|
||||
|
||||
/* limitter */
|
||||
#define Limit(val, max,min) { \
|
||||
if ( val > max ) val = max; \
|
||||
else if ( val < min ) val = min; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void memcpy32(int *dest, int *src, int count)
|
||||
{
|
||||
while (count--)
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
|
||||
void memset32(int *dest, int c, int count)
|
||||
{
|
||||
while (count--)
|
||||
*dest++ = c;
|
||||
}
|
||||
|
||||
|
||||
void mix_32_to_16l_stereo(short *dest, int *src, int count)
|
||||
{
|
||||
int l, r;
|
||||
|
||||
for (; count > 0; count--)
|
||||
{
|
||||
l = r = *dest;
|
||||
l += *src++;
|
||||
r += *src++;
|
||||
Limit( l, MAXOUT, MINOUT );
|
||||
Limit( r, MAXOUT, MINOUT );
|
||||
*dest++ = l;
|
||||
*dest++ = r;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void mix_32_to_16_mono(short *dest, int *src, int count)
|
||||
{
|
||||
int l;
|
||||
|
||||
for (; count > 0; count--)
|
||||
{
|
||||
l = *dest;
|
||||
l += *src++;
|
||||
Limit( l, MAXOUT, MINOUT );
|
||||
*dest++ = l;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue