sound change

This commit is contained in:
dborth 2008-09-13 00:47:54 +00:00
parent 73c621355f
commit 0985c86608
2 changed files with 48 additions and 47 deletions

View File

@ -61,7 +61,7 @@ int GCMemROM()
/*** Set internal sound information ***/ /*** Set internal sound information ***/
FCEUI_Sound(SAMPLERATE); FCEUI_Sound(SAMPLERATE);
FCEUI_SetSoundVolume(100); // 0-100 FCEUI_SetSoundVolume(100); // 0-100
FCEUI_SetSoundQuality(1); // 0 - low, 1 - high FCEUI_SetSoundQuality(0); // 0 - low, 1 - high
FCEUI_SetLowPass(0); FCEUI_SetLowPass(0);
InitialisePads(); InitialisePads();

View File

@ -26,46 +26,47 @@ static int whichab = 0; /*** Which Audio Buffer is in use ***/
static int isPlaying; /*** Is Playing ***/ static int isPlaying; /*** Is Playing ***/
static void AudioSwitchBuffers() static void AudioSwitchBuffers()
{ {
if ( buffSize[whichab] ) { if ( buffSize[whichab] )
AUDIO_StopDMA(); {
AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]); AUDIO_StopDMA();
DCFlushRange(audiobuffer[whichab], buffSize[whichab]); AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]);
AUDIO_StartDMA(); DCFlushRange(audiobuffer[whichab], buffSize[whichab]);
isPlaying = 0; AUDIO_StartDMA();
} isPlaying = 0;
}
whichab ^= 1; whichab ^= 1;
buffSize[whichab] = 0; buffSize[whichab] = 0;
} }
void InitialiseSound() void InitialiseSound()
{ {
AUDIO_Init(NULL); /*** Start audio subsystem ***/ AUDIO_Init(NULL); /*** Start audio subsystem ***/
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
AUDIO_RegisterDMACallback( AudioSwitchBuffers ); AUDIO_RegisterDMACallback( AudioSwitchBuffers );
buffSize[0] = buffSize[1] = 0; buffSize[0] = buffSize[1] = 0;
} }
void StartAudio() void StartAudio()
{ {
AUDIO_StartDMA(); AUDIO_StartDMA();
} }
void StopAudio() void StopAudio()
{ {
AUDIO_StopDMA(); AUDIO_StopDMA();
buffSize[0] = buffSize[1] = 0; buffSize[0] = buffSize[1] = 0;
} }
static inline unsigned short FLIP16(unsigned short b) static inline unsigned short FLIP16(unsigned short b)
{ {
return((b<<8)|((b>>8)&0xFF)); return((b<<8)|((b>>8)&0xFF));
} }
static inline u32 FLIP32(u32 b) static inline u32 FLIP32(u32 b)
{ {
return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) ); return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) );
} }
/**************************************************************************** /****************************************************************************
@ -79,37 +80,37 @@ static short MBuffer[ 8 * 96000 / 50 ];
void PlaySound( unsigned int *Buffer, int count ) void PlaySound( unsigned int *Buffer, int count )
{ {
int P; int P;
unsigned short *s = (unsigned short *)&MBuffer[0]; unsigned short *s = (unsigned short *)&MBuffer[0];
unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]]; unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]];
unsigned int c; unsigned int c;
int ms; int ms;
isWriting = 1; isWriting = 1;
for ( P = 0; P < count; P++ ) { for ( P = 0; P < count; P++ )
MBuffer[P] = Buffer[P]; {
} MBuffer[P] = Buffer[P];
}
/*** Now do Mono - Stereo Conversion ***/ /*** Now do Mono - Stereo Conversion ***/
ms = count; ms = count;
do do
{ {
c = 0xffff & *s++; c = 0xffff & *s++;
*d++ = (c | (c<<16)); *d++ = (c | (c<<16));
} while(--ms); } while(--ms);
buffSize[whichab] += ( count << 2 ); buffSize[whichab] += ( count << 2 );
/*** This is the kicker for the entire audio loop ***/ /*** This is the kicker for the entire audio loop ***/
if ( isPlaying == 0 ) if ( isPlaying == 0 )
{ {
if ( buffSize[whichab] > AUDIOBUFFER ) if ( buffSize[whichab] > AUDIOBUFFER )
{ {
isPlaying = 1; isPlaying = 1;
AudioSwitchBuffers(); AudioSwitchBuffers();
} }
} }
isWriting = 0;
isWriting = 0;
} }