From 2b23c6bb1d81a9becf6cd08728cbde040c7dc93a Mon Sep 17 00:00:00 2001 From: Joshua de Reeper Date: Thu, 30 Jan 2025 12:31:43 +0100 Subject: [PATCH] review changes --- src/audio/IAudioAPI.cpp | 19 ++++++++++++++++++- src/audio/IAudioAPI.h | 1 + src/config/CemuConfig.cpp | 2 -- src/config/CemuConfig.h | 2 +- src/gui/GeneralSettings2.cpp | 22 +--------------------- src/gui/GeneralSettings2.h | 2 +- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/audio/IAudioAPI.cpp b/src/audio/IAudioAPI.cpp index c8b66b6d..1ba109f9 100644 --- a/src/audio/IAudioAPI.cpp +++ b/src/audio/IAudioAPI.cpp @@ -129,6 +129,7 @@ AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(AudioType type, sint32 rate, sint3 audioAPIDev = CreateDevice(audio_api, device_description, rate, channels, samples_per_block, bits_per_sample); audioAPIDev->SetVolume(TV ? config.tv_volume : config.pad_volume); + return audioAPIDev; } @@ -220,7 +221,7 @@ AudioChannels IAudioAPI::AudioTypeToChannels(AudioType type) case Gamepad: return config.pad_channels; case Portal: - return config.portal_channels; + return kMono; default: return kMono; } @@ -241,3 +242,19 @@ std::wstring IAudioAPI::GetDeviceFromType(AudioType type) return L""; } } + +sint32 IAudioAPI::GetVolumeFromType(AudioType type) +{ + auto& config = GetConfig(); + switch (type) + { + case TV: + return config.tv_volume; + case Gamepad: + return config.pad_volume; + case Portal: + return config.portal_volume; + default: + return 0; + } +} diff --git a/src/audio/IAudioAPI.h b/src/audio/IAudioAPI.h index 43105370..34df421a 100644 --- a/src/audio/IAudioAPI.h +++ b/src/audio/IAudioAPI.h @@ -95,6 +95,7 @@ private: void InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample); static AudioChannels AudioTypeToChannels(AudioType type); static std::wstring GetDeviceFromType(AudioType type); + static sint32 GetVolumeFromType(AudioType type); }; diff --git a/src/config/CemuConfig.cpp b/src/config/CemuConfig.cpp index 26ec2631..809a5470 100644 --- a/src/config/CemuConfig.cpp +++ b/src/config/CemuConfig.cpp @@ -275,7 +275,6 @@ void CemuConfig::Load(XMLConfigParser& parser) tv_channels = audio.get("TVChannels", kStereo); pad_channels = audio.get("PadChannels", kStereo); input_channels = audio.get("InputChannels", kMono); - portal_channels = audio.get("PortalChannels", kMono); tv_volume = audio.get("TVVolume", 20); pad_volume = audio.get("PadVolume", 0); input_volume = audio.get("InputVolume", 20); @@ -520,7 +519,6 @@ void CemuConfig::Save(XMLConfigParser& parser) audio.set("TVChannels", tv_channels); audio.set("PadChannels", pad_channels); audio.set("InputChannels", input_channels); - audio.set("PortalChannels", portal_channels); audio.set("TVVolume", tv_volume); audio.set("PadVolume", pad_volume); audio.set("InputVolume", input_volume); diff --git a/src/config/CemuConfig.h b/src/config/CemuConfig.h index 0696301f..e8c7e237 100644 --- a/src/config/CemuConfig.h +++ b/src/config/CemuConfig.h @@ -479,7 +479,7 @@ struct CemuConfig // audio sint32 audio_api = 0; sint32 audio_delay = 2; - AudioChannels tv_channels = kStereo, pad_channels = kStereo, input_channels = kMono, portal_channels = kMono; + AudioChannels tv_channels = kStereo, pad_channels = kStereo, input_channels = kMono; sint32 tv_volume = 50, pad_volume = 0, input_volume = 50, portal_volume = 50; std::wstring tv_device{ L"default" }, pad_device, input_device, portal_device; diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index dafa32f8..4c23aedc 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -559,17 +559,6 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook) m_portal_device->Bind(wxEVT_CHOICE, &GeneralSettings2::OnAudioDeviceSelected, this); - const wxString audio_channel_drc_choices[] = { _("Mono") }; // mono for now only - - portal_audio_row->Add(new wxStaticText(box, wxID_ANY, _("Channels")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - m_portal_channels = new wxChoice(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, std::size(audio_channel_drc_choices), audio_channel_drc_choices); - - m_portal_channels->SetSelection(0); // set default to mono - - m_portal_channels->Bind(wxEVT_CHOICE, &GeneralSettings2::OnAudioChannelsSelected, this); - portal_audio_row->Add(m_portal_channels, 0, wxEXPAND | wxALL, 5); - portal_audio_row->AddSpacer(0); - portal_audio_row->Add(new wxStaticText(box, wxID_ANY, _("Volume")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); m_portal_volume = new wxSlider(box, wxID_ANY, 100, 0, 100); portal_audio_row->Add(m_portal_volume, 0, wxEXPAND | wxALL, 5); @@ -1030,7 +1019,6 @@ void GeneralSettings2::StoreConfig() config.pad_channels = kStereo; // (AudioChannels)m_pad_channels->GetSelection(); //config.input_channels = (AudioChannels)m_input_channels->GetSelection(); config.input_channels = kMono; // (AudioChannels)m_input_channels->GetSelection(); - config.portal_channels = kMono; // (AudioChannels)m_portal_channels->GetSelection(); config.tv_volume = m_tv_volume->GetValue(); config.pad_volume = m_pad_volume->GetValue(); @@ -1720,7 +1708,6 @@ void GeneralSettings2::ApplyConfig() m_pad_channels->SetSelection(0); //m_input_channels->SetSelection(config.pad_channels); m_input_channels->SetSelection(0); - m_portal_channels->SetSelection(0); SendSliderEvent(m_tv_volume, config.tv_volume); @@ -1975,7 +1962,7 @@ void GeneralSettings2::UpdateAudioDevice() } catch (std::runtime_error& ex) { - cemuLog_log(LogType::Force, "can't initialize pad audio: {}", ex.what()); + cemuLog_log(LogType::Force, "can't initialize portal audio: {}", ex.what()); } } } @@ -2010,13 +1997,6 @@ void GeneralSettings2::OnAudioChannelsSelected(wxCommandEvent& event) config.pad_channels = (AudioChannels)obj->GetSelection(); } - else if (obj == m_portal_channels) - { - if (config.portal_channels == (AudioChannels)obj->GetSelection()) - return; - - config.portal_channels = (AudioChannels)obj->GetSelection(); - } else cemu_assert_debug(false); diff --git a/src/gui/GeneralSettings2.h b/src/gui/GeneralSettings2.h index a37b9c1b..5e27d6e2 100644 --- a/src/gui/GeneralSettings2.h +++ b/src/gui/GeneralSettings2.h @@ -64,7 +64,7 @@ private: wxChoice* m_audio_api; wxSlider *m_audio_latency; wxSlider *m_tv_volume, *m_pad_volume, *m_input_volume, *m_portal_volume; - wxChoice *m_tv_channels, *m_pad_channels, *m_input_channels, *m_portal_channels; + wxChoice *m_tv_channels, *m_pad_channels, *m_input_channels; wxChoice *m_tv_device, *m_pad_device, *m_input_device, *m_portal_device; // Account