diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2017-04-12 20:27:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-12 20:27:26 +0200 |
| commit | 2151858fb10adcd37c67c814c4675ca5ab3ac607 (patch) | |
| tree | 675d28467827bc115dd58f012ba94054ee8c13fe /Source/Core/DolphinWX/Config/AudioConfigPane.cpp | |
| parent | 21544f8661986fd022d690600a2276f6aed59661 (diff) | |
| parent | cbaa00457a961b3aa0213da0f5282e13a69c610d (diff) | |
Merge pull request #5241 from MerryMage/stretch
Pitch-Preserving Audio Stretching
Diffstat (limited to 'Source/Core/DolphinWX/Config/AudioConfigPane.cpp')
| -rw-r--r-- | Source/Core/DolphinWX/Config/AudioConfigPane.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Source/Core/DolphinWX/Config/AudioConfigPane.cpp b/Source/Core/DolphinWX/Config/AudioConfigPane.cpp index 6a49499fe0..ec83542d15 100644 --- a/Source/Core/DolphinWX/Config/AudioConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/AudioConfigPane.cpp @@ -48,12 +48,21 @@ void AudioConfigPane::InitializeGUI() new wxSpinCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 30); m_audio_latency_label = new wxStaticText(this, wxID_ANY, _("Latency:")); + m_stretch_checkbox = new wxCheckBox(this, wxID_ANY, _("Enable Audio Stretching")); + m_stretch_label = new wxStaticText(this, wxID_ANY, _("Buffer Size:")); + m_stretch_slider = + new DolphinSlider(this, wxID_ANY, 80, 5, 300, wxDefaultPosition, wxDefaultSize); + m_stretch_text = new wxStaticText(this, wxID_ANY, ""); + m_audio_backend_choice->SetToolTip( _("Changing this will have no effect while the emulator is running.")); m_audio_latency_spinctrl->SetToolTip(_("Sets the latency (in ms). Higher values may reduce audio " "crackling. Certain backends only.")); m_dpl2_decoder_checkbox->SetToolTip( _("Enables Dolby Pro Logic II emulation using 5.1 surround. Certain backends only.")); + m_stretch_checkbox->SetToolTip(_("Enables stretching of the audio to match emulation speed.")); + m_stretch_slider->SetToolTip(_("Size of stretch buffer in milliseconds. " + "Values too low may cause audio crackling.")); const int space5 = FromDIP(5); @@ -93,12 +102,32 @@ void AudioConfigPane::InitializeGUI() dsp_audio_sizer->Add(volume_sizer, 0, wxEXPAND | wxTOP | wxBOTTOM, space5); dsp_audio_sizer->AddSpacer(space5); + wxGridBagSizer* const latency_sizer = new wxGridBagSizer(); + latency_sizer->Add(m_stretch_slider, wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + latency_sizer->Add(m_stretch_text, wxGBPosition(0, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + + wxGridBagSizer* const stretching_grid_sizer = new wxGridBagSizer(space5, space5); + stretching_grid_sizer->Add(m_stretch_checkbox, wxGBPosition(0, 0), wxGBSpan(1, 2), + wxALIGN_CENTER_VERTICAL); + stretching_grid_sizer->Add(m_stretch_label, wxGBPosition(1, 0), wxDefaultSpan, + wxALIGN_CENTER_VERTICAL); + stretching_grid_sizer->Add(latency_sizer, wxGBPosition(1, 1), wxDefaultSpan, + wxALIGN_CENTER_VERTICAL); + + wxStaticBoxSizer* const stretching_box_sizer = + new wxStaticBoxSizer(wxVERTICAL, this, _("Audio Stretching Settings")); + stretching_box_sizer->AddSpacer(space5); + stretching_box_sizer->Add(stretching_grid_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + stretching_box_sizer->AddSpacer(space5); + wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->AddSpacer(space5); main_sizer->Add(dsp_audio_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); main_sizer->AddSpacer(space5); main_sizer->Add(backend_static_box_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); main_sizer->AddSpacer(space5); + main_sizer->Add(stretching_box_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5); + main_sizer->AddSpacer(space5); SetSizerAndFit(main_sizer); } @@ -119,6 +148,12 @@ void AudioConfigPane::LoadGUIValues() m_volume_text->SetLabel(wxString::Format("%d %%", SConfig::GetInstance().m_Volume)); m_dpl2_decoder_checkbox->SetValue(startup_params.bDPL2Decoder); m_audio_latency_spinctrl->SetValue(startup_params.iLatency); + m_stretch_checkbox->SetValue(startup_params.m_audio_stretch); + m_stretch_slider->Enable(startup_params.m_audio_stretch); + m_stretch_slider->SetValue(startup_params.m_audio_stretch_max_latency); + m_stretch_text->Enable(startup_params.m_audio_stretch); + m_stretch_text->SetLabel(wxString::Format("%d ms", startup_params.m_audio_stretch_max_latency)); + m_stretch_label->Enable(startup_params.m_audio_stretch); } void AudioConfigPane::ToggleBackendSpecificControls(const std::string& backend) @@ -150,6 +185,9 @@ void AudioConfigPane::BindEvents() m_audio_latency_spinctrl->Bind(wxEVT_SPINCTRL, &AudioConfigPane::OnLatencySpinCtrlChanged, this); m_audio_latency_spinctrl->Bind(wxEVT_UPDATE_UI, &WxEventUtils::OnEnableIfCoreNotRunning); + + m_stretch_checkbox->Bind(wxEVT_CHECKBOX, &AudioConfigPane::OnStretchCheckBoxChanged, this); + m_stretch_slider->Bind(wxEVT_SLIDER, &AudioConfigPane::OnStretchSliderChanged, this); } void AudioConfigPane::OnDSPEngineRadioBoxChanged(wxCommandEvent& event) @@ -186,6 +224,21 @@ void AudioConfigPane::OnLatencySpinCtrlChanged(wxCommandEvent& event) SConfig::GetInstance().iLatency = m_audio_latency_spinctrl->GetValue(); } +void AudioConfigPane::OnStretchCheckBoxChanged(wxCommandEvent& event) +{ + const bool stretch_enabled = m_stretch_checkbox->GetValue(); + SConfig::GetInstance().m_audio_stretch = stretch_enabled; + m_stretch_slider->Enable(stretch_enabled); + m_stretch_text->Enable(stretch_enabled); + m_stretch_label->Enable(stretch_enabled); +} + +void AudioConfigPane::OnStretchSliderChanged(wxCommandEvent& event) +{ + SConfig::GetInstance().m_audio_stretch_max_latency = m_stretch_slider->GetValue(); + m_stretch_text->SetLabel(wxString::Format("%d ms", m_stretch_slider->GetValue())); +} + void AudioConfigPane::PopulateBackendChoiceBox() { for (const std::string& backend : AudioCommon::GetSoundBackends()) |
