mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-04 15:40:02 +00:00
AudioConfigPane: Allow user-configuration of audio stretching
This commit is contained in:
parent
26514358f4
commit
71e748b68f
@ -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())
|
||||
|
@ -33,6 +33,8 @@ private:
|
||||
void OnVolumeSliderChanged(wxCommandEvent&);
|
||||
void OnAudioBackendChanged(wxCommandEvent&);
|
||||
void OnLatencySpinCtrlChanged(wxCommandEvent&);
|
||||
void OnStretchCheckBoxChanged(wxCommandEvent&);
|
||||
void OnStretchSliderChanged(wxCommandEvent&);
|
||||
|
||||
wxArrayString m_dsp_engine_strings;
|
||||
wxArrayString m_audio_backend_strings;
|
||||
@ -44,4 +46,8 @@ private:
|
||||
wxChoice* m_audio_backend_choice;
|
||||
wxSpinCtrl* m_audio_latency_spinctrl;
|
||||
wxStaticText* m_audio_latency_label;
|
||||
wxCheckBox* m_stretch_checkbox;
|
||||
wxStaticText* m_stretch_label;
|
||||
DolphinSlider* m_stretch_slider;
|
||||
wxStaticText* m_stretch_text;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user