Fix the sound crack problem in v9

This commit is contained in:
simon.kagstrom 2009-04-05 14:38:04 +00:00
parent a230053a91
commit bb77c8f23b
4 changed files with 14 additions and 8 deletions

View File

@ -9,6 +9,14 @@
TODO: Handle Run/Stop in virtual keyboard (?) 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 <simon.kagstrom@gmail.com>,
version 9: version 9:
* Fix a buffer overflow in the network status string... * Fix a buffer overflow in the network status string...

View File

@ -279,10 +279,8 @@ void MOS6581::SetState(MOS6581State *ss)
#if defined(AMIGA) || defined(__riscos__) #if defined(AMIGA) || defined(__riscos__)
const uint32 SAMPLE_FREQ = 22050; // Sample output frequency in Hz const uint32 SAMPLE_FREQ = 22050; // Sample output frequency in Hz
#elif defined(GEKKO)
const uint32 SAMPLE_FREQ = 48000;
#else #else
const uint32 SAMPLE_FREQ = 44100; // Sample output frequency in Hz const uint32 SAMPLE_FREQ = 32000; // Sample output frequency in Hz
#endif #endif
const uint32 SID_FREQ = 985248; // SID frequency in Hz 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) const uint32 CALC_FREQ = 50; // Frequency at which calc_buffer is called in Hz (should be 50Hz)

View File

@ -70,11 +70,11 @@ void DigitalRenderer::init_sound(void)
ioctl(devfd, SNDCTL_DSP_SETFRAGMENT, &arg); ioctl(devfd, SNDCTL_DSP_SETFRAGMENT, &arg);
arg = 0; arg = 0;
ioctl(devfd, SNDCTL_DSP_STEREO, &arg); ioctl(devfd, SNDCTL_DSP_STEREO, &arg);
arg = 44100; arg = 32000;
ioctl(devfd, SNDCTL_DSP_SPEED, &arg); ioctl(devfd, SNDCTL_DSP_SPEED, &arg);
ioctl(devfd, SOUND_PCM_READ_RATE, &arg); ioctl(devfd, SOUND_PCM_READ_RATE, &arg);
if (arg < 43000 || arg > 45000) //if (arg < 43000 || arg > 45000)
return; // return;
ioctl(devfd, SNDCTL_DSP_GETBLKSIZE, &sndbufsize); ioctl(devfd, SNDCTL_DSP_GETBLKSIZE, &sndbufsize);
sound_buffer = new int16[sndbufsize]; sound_buffer = new int16[sndbufsize];

View File

@ -13,7 +13,7 @@
#include <gccore.h> #include <gccore.h>
#include <string.h> #include <string.h>
#define SAMPLERATE 48000 #define SAMPLERATE 32000
#define MIXBUFSIZE_BYTES 16000 #define MIXBUFSIZE_BYTES 16000
#define MIXBUFSIZE_SHORT (MIXBUFSIZE_BYTES / 2) #define MIXBUFSIZE_SHORT (MIXBUFSIZE_BYTES / 2)
@ -90,7 +90,7 @@ static void AudioSwitchBuffers()
void InitialiseAudio() void InitialiseAudio()
{ {
AUDIO_Init(NULL); // Start audio subsystem AUDIO_Init(NULL); // Start audio subsystem
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ);
AUDIO_RegisterDMACallback( AudioSwitchBuffers ); AUDIO_RegisterDMACallback( AudioSwitchBuffers );
memset(soundbuffer, 0, SOUNDBUFSIZE*2); memset(soundbuffer, 0, SOUNDBUFSIZE*2);
memset(mixbuffer, 0, MIXBUFSIZE_BYTES); memset(mixbuffer, 0, MIXBUFSIZE_BYTES);