From 9383abc719f33de9b4a9e947491e15457bb910af Mon Sep 17 00:00:00 2001 From: bgk Date: Tue, 30 Dec 2008 12:14:04 +0000 Subject: [PATCH] GTK : Added an option to allow a sound sample rate of 48 000 Hz (finally ...) --- src/Sound.cpp | 2 +- src/common/SoundSDL.cpp | 2 +- src/gtk/soundconfig.cpp | 16 +++++++++++----- src/gtk/ui/sound.ui | 5 ++++- src/gtk/window.cpp | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Sound.cpp b/src/Sound.cpp index 101750ba..652641d3 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -40,7 +40,7 @@ extern bool stopState; // TODO: silence sound when true int const SOUND_CLOCK_TICKS_ = 167772; // 1/100 second -static u16 soundFinalWave [1470]; +static u16 soundFinalWave [1600]; long soundSampleRate = 44100; bool soundInterpolation = true; bool soundPaused = true; diff --git a/src/common/SoundSDL.cpp b/src/common/SoundSDL.cpp index c116e389..ef170149 100644 --- a/src/common/SoundSDL.cpp +++ b/src/common/SoundSDL.cpp @@ -98,7 +98,7 @@ bool SoundSDL::init(long sampleRate) { SDL_AudioSpec audio; - _bufferLen = sampleRate / 15; + _bufferLen = sampleRate * 4 / 60; audio.freq = sampleRate; audio.format = AUDIO_S16SYS; diff --git a/src/gtk/soundconfig.cpp b/src/gtk/soundconfig.cpp index 488d5220..4309a6e6 100644 --- a/src/gtk/soundconfig.cpp +++ b/src/gtk/soundconfig.cpp @@ -60,15 +60,18 @@ void SoundConfigDialog::vSetConfig(Config::Section * _poConfig, VBA::Window * _p long iSoundSampleRate = m_poConfig->oGetKey("sample_rate"); switch (iSoundSampleRate) { - default: - case 44100: - m_poRateComboBox->set_active(2); + case 11025: + m_poRateComboBox->set_active(0); break; case 22050: m_poRateComboBox->set_active(1); break; - case 11025: - m_poRateComboBox->set_active(0); + default: + case 44100: + m_poRateComboBox->set_active(2); + break; + case 48000: + m_poRateComboBox->set_active(3); break; } } @@ -120,6 +123,9 @@ void SoundConfigDialog::vOnRateChanged() default: m_poConfig->vSetKey("sample_rate", 44100); break; + case 3: // 48 KHz + m_poConfig->vSetKey("sample_rate", 48000); + break; } m_poWindow->vApplyConfigSoundSampleRate(); diff --git a/src/gtk/ui/sound.ui b/src/gtk/ui/sound.ui index 9b2600a3..bf0a8790 100644 --- a/src/gtk/ui/sound.ui +++ b/src/gtk/ui/sound.ui @@ -35,7 +35,10 @@ 22 KHz - 44 KHz + 44.1 KHz + + + 48 KHz diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index effd2f09..3097be93 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -92,7 +92,7 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : m_iSaveTypeMin (SaveAuto), m_iSaveTypeMax (SaveNone), m_iSoundSampleRateMin(11025), - m_iSoundSampleRateMax(44100), + m_iSoundSampleRateMax(48000), m_fSoundVolumeMin (0.50f), m_fSoundVolumeMax (2.00f), m_iEmulatorTypeMin(EmulatorAuto),