diff --git a/source/sound/Fir_Resampler.h b/source/sound/Fir_Resampler.h index cd576d4..12f6f85 100644 --- a/source/sound/Fir_Resampler.h +++ b/source/sound/Fir_Resampler.h @@ -10,7 +10,7 @@ #define WRITE_OFFSET (WIDTH * STEREO) - STEREO #define GAIN 1.0 -typedef short int sample_t; +typedef signed long int sample_t; extern int Fir_Resampler_initialize( int new_size ); extern void Fir_Resampler_shutdown( void ); diff --git a/source/sound/sound.c b/source/sound/sound.c index 5953ca2..2ca16a6 100644 --- a/source/sound/sound.c +++ b/source/sound/sound.c @@ -54,7 +54,7 @@ static inline void fm_update(unsigned int cycles) } /* select input sample buffer */ - int16 *buffer = Fir_Resampler_buffer(); + int32 *buffer = Fir_Resampler_buffer(); if (buffer) { Fir_Resampler_write(cnt << 1); diff --git a/source/sound/ym2612.c b/source/sound/ym2612.c index ff7c37f..37e58ba 100644 --- a/source/sound/ym2612.c +++ b/source/sound/ym2612.c @@ -2028,7 +2028,7 @@ unsigned int YM2612Read(void) } /* Generate 16 bits samples for ym2612 */ -void YM2612Update(short int *buffer, int length) +void YM2612Update(INT32 *buffer, int length) { int i; long int lt,rt; diff --git a/source/sound/ym2612.h b/source/sound/ym2612.h index fac39de..3221d4c 100644 --- a/source/sound/ym2612.h +++ b/source/sound/ym2612.h @@ -21,7 +21,7 @@ extern int YM2612Init(float clock, int rate); extern int YM2612ResetChip(void); -extern void YM2612Update(short int *buffer, int length); +extern void YM2612Update(INT32 *buffer, int length); extern void YM2612Write(unsigned int a, unsigned int v); extern unsigned int YM2612Read(void); extern unsigned char *YM2612GetContextPtr(void); diff --git a/source/system.c b/source/system.c index c8f90df..10f215f 100644 --- a/source/system.c +++ b/source/system.c @@ -64,7 +64,7 @@ int audio_update (void) uint32 factora = (config.lp_range << 16) / 100; uint32 factorb = 0x10000 - factora; - int16 *fm = snd.fm.buffer; + int32 *fm = snd.fm.buffer; int16 *psg = snd.psg.buffer; #ifdef NGC @@ -154,7 +154,7 @@ int audio_update (void) rrp = rr; /* keep remaining samples for next frame */ - memcpy(snd.fm.buffer, fm, (snd.fm.pos - snd.fm.buffer) << 1); + memcpy(snd.fm.buffer, fm, (snd.fm.pos - snd.fm.buffer) << 2); memcpy(snd.psg.buffer, psg, (snd.psg.pos - snd.psg.buffer) << 1); #ifdef LOGSOUND @@ -191,12 +191,20 @@ int audio_init (int samplerate, float framerate) #endif /* SN76489 stream buffers */ +#ifndef NGC snd.psg.buffer = (int16 *) malloc(snd.buffer_size * sizeof(int16)); +#else + snd.psg.buffer = (int16 *) memalign(32, snd.buffer_size * sizeof(int16)); +#endif if (!snd.psg.buffer) return (-1); /* YM2612 stream buffers */ - snd.fm.buffer = (int32 *) malloc(snd.buffer_size * sizeof(int16) * 2); +#ifndef NGC + snd.fm.buffer = (int32 *) malloc(snd.buffer_size * sizeof(int32) * 2); +#else + snd.fm.buffer = (int32 *) memalign(32,snd.buffer_size * sizeof(int32) * 2); +#endif if (!snd.fm.buffer) return (-1); @@ -241,7 +249,7 @@ void audio_reset(void) if (snd.psg.buffer) memset (snd.psg.buffer, 0, snd.buffer_size * sizeof(int16)); if (snd.fm.buffer) - memset (snd.fm.buffer, 0, snd.buffer_size * sizeof(int16) * 2); + memset (snd.fm.buffer, 0, snd.buffer_size * sizeof(int32) * 2); } /**************************************************************** diff --git a/source/system.h b/source/system.h index 1e8bc6e..adf9d76 100644 --- a/source/system.h +++ b/source/system.h @@ -61,8 +61,8 @@ typedef struct int16 *buffer[2]; /* Signed 16-bit stereo sound data */ struct { - int16 *pos; - int16 *buffer; + int32 *pos; + int32 *buffer; } fm; struct {