From bb77c8f23bd8b2b5e9ce97f89ab0f9675ef189a2 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 5 Apr 2009 14:38:04 +0000 Subject: [PATCH] Fix the sound crack problem in v9 --- CHANGES.WII | 8 ++++++++ Src/SID.cpp | 4 +--- Src/SID_linux.h | 6 +++--- Src/gcaudio.c | 4 ++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGES.WII b/CHANGES.WII index 57fda0e..f74b183 100644 --- a/CHANGES.WII +++ b/CHANGES.WII @@ -9,6 +9,14 @@ TODO: Handle Run/Stop in virtual keyboard (?) +version 10: + * Use 32KHz sound samplerate. This fixes much of the cracking sound + problems from v9. It also allows sound to be transferred via the network + to both Linux/Wii (sharing the same sample rate) and lowering the + network transfer rate. + + -- Simon Kagstrom , + version 9: * Fix a buffer overflow in the network status string... diff --git a/Src/SID.cpp b/Src/SID.cpp index 7b98bd9..78aa2b4 100644 --- a/Src/SID.cpp +++ b/Src/SID.cpp @@ -279,10 +279,8 @@ void MOS6581::SetState(MOS6581State *ss) #if defined(AMIGA) || defined(__riscos__) const uint32 SAMPLE_FREQ = 22050; // Sample output frequency in Hz -#elif defined(GEKKO) -const uint32 SAMPLE_FREQ = 48000; #else -const uint32 SAMPLE_FREQ = 44100; // Sample output frequency in Hz +const uint32 SAMPLE_FREQ = 32000; // Sample output frequency in Hz #endif const uint32 SID_FREQ = 985248; // SID frequency in Hz const uint32 CALC_FREQ = 50; // Frequency at which calc_buffer is called in Hz (should be 50Hz) diff --git a/Src/SID_linux.h b/Src/SID_linux.h index 43f31d1..1064403 100644 --- a/Src/SID_linux.h +++ b/Src/SID_linux.h @@ -70,11 +70,11 @@ void DigitalRenderer::init_sound(void) ioctl(devfd, SNDCTL_DSP_SETFRAGMENT, &arg); arg = 0; ioctl(devfd, SNDCTL_DSP_STEREO, &arg); - arg = 44100; + arg = 32000; ioctl(devfd, SNDCTL_DSP_SPEED, &arg); ioctl(devfd, SOUND_PCM_READ_RATE, &arg); - if (arg < 43000 || arg > 45000) - return; + //if (arg < 43000 || arg > 45000) + // return; ioctl(devfd, SNDCTL_DSP_GETBLKSIZE, &sndbufsize); sound_buffer = new int16[sndbufsize]; diff --git a/Src/gcaudio.c b/Src/gcaudio.c index 5cd945e..8a03cd6 100644 --- a/Src/gcaudio.c +++ b/Src/gcaudio.c @@ -13,7 +13,7 @@ #include #include -#define SAMPLERATE 48000 +#define SAMPLERATE 32000 #define MIXBUFSIZE_BYTES 16000 #define MIXBUFSIZE_SHORT (MIXBUFSIZE_BYTES / 2) @@ -90,7 +90,7 @@ static void AudioSwitchBuffers() void InitialiseAudio() { AUDIO_Init(NULL); // Start audio subsystem - AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); + AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ); AUDIO_RegisterDMACallback( AudioSwitchBuffers ); memset(soundbuffer, 0, SOUNDBUFSIZE*2); memset(mixbuffer, 0, MIXBUFSIZE_BYTES);