diff --git a/TODO_audio.md b/TODO_audio.md index 6df170ff8..3f5c5ccbe 100644 --- a/TODO_audio.md +++ b/TODO_audio.md @@ -1,9 +1,9 @@ # Missing features * Reimplement target FPS mode - * Implement Lanzcos resampling * Fixup OpenGL sync, ensure that FB only rerenders after a frame has been generated # Cleanup + * Remove or turn sterr output into log messages * Document EmulationTiming diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index a7bbd416d..2f42f5f85 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -246,12 +246,30 @@ void SoundSDL2::initResampler() return nextFragment; }; - myResampler = make_unique( - Resampler::Format(myAudioQueue->sampleRate(), myAudioQueue->fragmentSize(), myAudioQueue->isStereo()), - Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1), - nextFragmentCallback, - 2 - ); + Resampler::Format formatFrom = + Resampler::Format(myAudioQueue->sampleRate(), myAudioQueue->fragmentSize(), myAudioQueue->isStereo()); + Resampler::Format formatTo = + Resampler::Format(myHardwareSpec.freq, myHardwareSpec.samples, myHardwareSpec.channels > 1); + + int quality = myOSystem.settings().getInt("resampling.quality"); + + switch (quality) { + case 1: + myResampler = make_unique(formatFrom, formatTo, nextFragmentCallback); + (cerr << "resampling quality 1: using nearest neighbor resampling\n").flush(); + break; + + default: + case 2: + (cerr << "resampling quality 2: using nearest Lanczos resampling, a = 2\n").flush(); + myResampler = make_unique(formatFrom, formatTo, nextFragmentCallback, 2); + break; + + case 3: + (cerr << "resampling quality 3: using nearest Lanczos resampling, a = 3\n").flush(); + myResampler = make_unique(formatFrom, formatTo, nextFragmentCallback, 3); + break; + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index b54c366ed..99c223bfb 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -71,8 +71,9 @@ Settings::Settings(OSystem& osystem) // Sound options setInternal("sound", "true"); setInternal("fragsize", "512"); - setInternal("freq", "31400"); + setInternal("freq", "44100"); setInternal("volume", "100"); + setInternal("resampling.quality", "2"); // Input event options setInternal("keymap", ""); @@ -362,8 +363,10 @@ void Settings::validate() i = getInt("volume"); if(i < 0 || i > 100) setInternal("volume", "100"); i = getInt("freq"); - if(!(i == 11025 || i == 22050 || i == 31400 || i == 44100 || i == 48000)) - setInternal("freq", "31400"); + if(!(i == 44100 || i == 48000 || i == 96000)) + setInternal("freq", "44100"); + i = getInt("resampling.quality"); + if (i < 1 || i > 3) setInternal("resampling.quality", 2); #endif i = getInt("joydeadzone"); @@ -443,10 +446,11 @@ void Settings::usage() const << " -uimessages <1|0> Show onscreen UI messages for different events\n" << endl #ifdef SOUND_SUPPORT - << " -sound <1|0> Enable sound generation\n" - << " -fragsize The size of sound fragments (must be a power of two)\n" - << " -freq Set sound sample output frequency (11025|22050|31400|44100|48000)\n" - << " -volume Set the volume (0 - 100)\n" + << " -sound <1|0> Enable sound generation\n" + << " -fragsize The size of sound fragments (must be a power of two)\n" + << " -freq Set sound sample output frequency (44100|48000|96000)\n" + << " -resampling.quality Resampling quality (1 -3), default: 2\n" + << " -volume Set the volume (0 - 100)\n" << endl #endif << " -tia.zoom Use the specified zoom level (windowed mode) for TIA image\n" diff --git a/src/gui/AudioDialog.cxx b/src/gui/AudioDialog.cxx index 74c15668f..1eb93c36a 100644 --- a/src/gui/AudioDialog.cxx +++ b/src/gui/AudioDialog.cxx @@ -85,11 +85,9 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent, // Output frequency items.clear(); - VarList::push_back(items, "11025 Hz", "11025"); - VarList::push_back(items, "22050 Hz", "22050"); - VarList::push_back(items, "31400 Hz", "31400"); VarList::push_back(items, "44100 Hz", "44100"); VarList::push_back(items, "48000 Hz", "48000"); + VarList::push_back(items, "96000 Hz", "96000"); myFreqPopup = new PopUpWidget(this, font, xpos, ypos, pwidth, lineHeight, items, "Frequency (*) ", lwidth);