mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-03 21:41:19 +12:00
make portal audio a setting
This commit is contained in:
parent
1f3b97216f
commit
67f41245da
8 changed files with 193 additions and 48 deletions
|
@ -209,7 +209,7 @@ class BootSoundPlayer
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bootSndAudioDev = IAudioAPI::CreateDeviceFromConfig(true, sampleRate, nChannels, samplesPerBlock, bitsPerSample);
|
bootSndAudioDev = IAudioAPI::CreateDeviceFromConfig(IAudioAPI::AudioType::TV, sampleRate, nChannels, samplesPerBlock, bitsPerSample);
|
||||||
if(!bootSndAudioDev)
|
if(!bootSndAudioDev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -566,28 +566,9 @@ namespace nsyshid
|
||||||
|
|
||||||
if (!g_portalAudio)
|
if (!g_portalAudio)
|
||||||
{
|
{
|
||||||
auto& config = GetConfig();
|
|
||||||
auto& selectedDevice = L"default";
|
|
||||||
|
|
||||||
const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api;
|
|
||||||
IAudioAPI::DeviceDescriptionPtr device_description;
|
|
||||||
if (IAudioAPI::IsAudioAPIAvailable(audio_api))
|
|
||||||
{
|
|
||||||
auto devices = IAudioAPI::GetDevices(audio_api);
|
|
||||||
const auto it = std::find_if(devices.begin(), devices.end(), [&selectedDevice](const auto& d) {
|
|
||||||
return d->GetIdentifier() == selectedDevice;
|
|
||||||
});
|
|
||||||
if (it != devices.end())
|
|
||||||
{
|
|
||||||
device_description = *it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!device_description)
|
|
||||||
throw std::runtime_error("failed to find selected device while trying to create audio device");
|
|
||||||
|
|
||||||
// Portal audio is mono channel, 16 bit audio.
|
// Portal audio is mono channel, 16 bit audio.
|
||||||
// Audio is unsigned 16 bit, supplied as 64 bytes which is 32 samples per block
|
// Audio is unsigned 16 bit, supplied as 64 bytes which is 32 samples per block
|
||||||
g_portalAudio = IAudioAPI::CreateDevice((IAudioAPI::AudioAPI)GetConfig().audio_api, device_description, 8000, 1, 32, 16);
|
g_portalAudio = IAudioAPI::CreateDeviceFromConfig(IAudioAPI::AudioType::Portal, 8000, 32, 16);
|
||||||
}
|
}
|
||||||
std::array<sint16, 32> mono_samples;
|
std::array<sint16, 32> mono_samples;
|
||||||
for (unsigned int i = 0; i < mono_samples.size(); ++i)
|
for (unsigned int i = 0; i < mono_samples.size(); ++i)
|
||||||
|
|
|
@ -404,7 +404,7 @@ namespace snd_core
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
g_tvAudio = IAudioAPI::CreateDeviceFromConfig(true, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16);
|
g_tvAudio = IAudioAPI::CreateDeviceFromConfig(IAudioAPI::AudioType::TV, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16);
|
||||||
}
|
}
|
||||||
catch (std::runtime_error& ex)
|
catch (std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
|
@ -417,7 +417,7 @@ namespace snd_core
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
g_padAudio = IAudioAPI::CreateDeviceFromConfig(false, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16);
|
g_padAudio = IAudioAPI::CreateDeviceFromConfig(IAudioAPI::AudioType::Gamepad, 48000, snd_core::AX_SAMPLES_PER_3MS_48KHZ * AX_FRAMES_PER_GROUP, 16);
|
||||||
if(g_padAudio)
|
if(g_padAudio)
|
||||||
g_padVolume = g_padAudio->GetVolume();
|
g_padVolume = g_padAudio->GetVolume();
|
||||||
}
|
}
|
||||||
|
@ -442,6 +442,11 @@ namespace snd_core
|
||||||
g_padAudio->Stop();
|
g_padAudio->Stop();
|
||||||
g_padAudio.reset();
|
g_padAudio.reset();
|
||||||
}
|
}
|
||||||
|
if (g_portalAudio)
|
||||||
|
{
|
||||||
|
g_portalAudio->Stop();
|
||||||
|
g_portalAudio.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AXOut_updateDevicePlayState(bool isPlaying)
|
void AXOut_updateDevicePlayState(bool isPlaying)
|
||||||
|
|
|
@ -81,7 +81,7 @@ void IAudioAPI::InitializeStatic()
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
s_availableApis[DirectSound] = true;
|
s_availableApis[DirectSound] = true;
|
||||||
s_availableApis[XAudio2] = XAudio2API::InitializeStatic();
|
s_availableApis[XAudio2] = XAudio2API::InitializeStatic();
|
||||||
if(!s_availableApis[XAudio2]) // don't try to initialize the older lib if the newer version is available
|
if (!s_availableApis[XAudio2]) // don't try to initialize the older lib if the newer version is available
|
||||||
s_availableApis[XAudio27] = XAudio27API::InitializeStatic();
|
s_availableApis[XAudio27] = XAudio27API::InitializeStatic();
|
||||||
#endif
|
#endif
|
||||||
#if HAS_CUBEB
|
#if HAS_CUBEB
|
||||||
|
@ -98,30 +98,29 @@ bool IAudioAPI::IsAudioAPIAvailable(AudioAPI api)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(bool TV, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample)
|
AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(AudioType type, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample)
|
||||||
{
|
{
|
||||||
auto& config = GetConfig();
|
sint32 channels = CemuConfig::AudioChannelsToNChannels(AudioTypeToChannels(type));
|
||||||
sint32 channels = CemuConfig::AudioChannelsToNChannels(TV ? config.tv_channels : config.pad_channels);
|
|
||||||
return CreateDeviceFromConfig(TV, rate, channels, samples_per_block, bits_per_sample);
|
return CreateDeviceFromConfig(TV, rate, channels, samples_per_block, bits_per_sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(bool TV, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample)
|
AudioAPIPtr IAudioAPI::CreateDeviceFromConfig(AudioType type, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample)
|
||||||
{
|
{
|
||||||
AudioAPIPtr audioAPIDev;
|
AudioAPIPtr audioAPIDev;
|
||||||
|
|
||||||
auto& config = GetConfig();
|
auto& config = GetConfig();
|
||||||
|
|
||||||
const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api;
|
const auto audio_api = (IAudioAPI::AudioAPI)config.audio_api;
|
||||||
auto& selectedDevice = TV ? config.tv_device : config.pad_device;
|
auto selectedDevice = GetDeviceFromType(type);
|
||||||
|
|
||||||
if(selectedDevice.empty())
|
if (selectedDevice.empty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
IAudioAPI::DeviceDescriptionPtr device_description;
|
IAudioAPI::DeviceDescriptionPtr device_description;
|
||||||
if (IAudioAPI::IsAudioAPIAvailable(audio_api))
|
if (IAudioAPI::IsAudioAPIAvailable(audio_api))
|
||||||
{
|
{
|
||||||
auto devices = IAudioAPI::GetDevices(audio_api);
|
auto devices = IAudioAPI::GetDevices(audio_api);
|
||||||
const auto it = std::find_if(devices.begin(), devices.end(), [&selectedDevice](const auto& d) {return d->GetIdentifier() == selectedDevice; });
|
const auto it = std::find_if(devices.begin(), devices.end(), [&selectedDevice](const auto& d) { return d->GetIdentifier() == selectedDevice; });
|
||||||
if (it != devices.end())
|
if (it != devices.end())
|
||||||
device_description = *it;
|
device_description = *it;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +137,7 @@ AudioAPIPtr IAudioAPI::CreateDevice(AudioAPI api, const DeviceDescriptionPtr& de
|
||||||
if (!IsAudioAPIAvailable(api))
|
if (!IsAudioAPIAvailable(api))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
switch(api)
|
switch (api)
|
||||||
{
|
{
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
case DirectSound:
|
case DirectSound:
|
||||||
|
@ -158,11 +157,11 @@ AudioAPIPtr IAudioAPI::CreateDevice(AudioAPI api, const DeviceDescriptionPtr& de
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if HAS_CUBEB
|
#if HAS_CUBEB
|
||||||
case Cubeb:
|
case Cubeb:
|
||||||
{
|
{
|
||||||
const auto tmp = std::dynamic_pointer_cast<CubebAPI::CubebDeviceDescription>(device);
|
const auto tmp = std::dynamic_pointer_cast<CubebAPI::CubebDeviceDescription>(device);
|
||||||
return std::make_unique<CubebAPI>(tmp->GetDeviceId(), samplerate, channels, samples_per_block, bits_per_sample);
|
return std::make_unique<CubebAPI>(tmp->GetDeviceId(), samplerate, channels, samples_per_block, bits_per_sample);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error(fmt::format("invalid audio api: {}", api));
|
throw std::runtime_error(fmt::format("invalid audio api: {}", api));
|
||||||
|
@ -174,7 +173,7 @@ std::vector<IAudioAPI::DeviceDescriptionPtr> IAudioAPI::GetDevices(AudioAPI api)
|
||||||
if (!IsAudioAPIAvailable(api))
|
if (!IsAudioAPIAvailable(api))
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
switch(api)
|
switch (api)
|
||||||
{
|
{
|
||||||
#if BOOST_OS_WINDOWS
|
#if BOOST_OS_WINDOWS
|
||||||
case DirectSound:
|
case DirectSound:
|
||||||
|
@ -210,3 +209,35 @@ uint32 IAudioAPI::GetAudioDelay() const
|
||||||
{
|
{
|
||||||
return m_audioDelayOverride > 0 ? m_audioDelayOverride : s_audioDelay;
|
return m_audioDelayOverride > 0 ? m_audioDelayOverride : s_audioDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioChannels IAudioAPI::AudioTypeToChannels(AudioType type)
|
||||||
|
{
|
||||||
|
auto& config = GetConfig();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case TV:
|
||||||
|
return config.tv_channels;
|
||||||
|
case Gamepad:
|
||||||
|
return config.pad_channels;
|
||||||
|
case Portal:
|
||||||
|
return config.portal_channels;
|
||||||
|
default:
|
||||||
|
return kMono;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring IAudioAPI::GetDeviceFromType(AudioType type)
|
||||||
|
{
|
||||||
|
auto& config = GetConfig();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case TV:
|
||||||
|
return config.tv_device;
|
||||||
|
case Gamepad:
|
||||||
|
return config.pad_device;
|
||||||
|
case Portal:
|
||||||
|
return config.portal_device;
|
||||||
|
default:
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <mmreg.h>
|
#include <mmreg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "config/CemuConfig.h"
|
||||||
|
|
||||||
class IAudioAPI
|
class IAudioAPI
|
||||||
{
|
{
|
||||||
friend class GeneralSettings2;
|
friend class GeneralSettings2;
|
||||||
|
@ -30,6 +32,13 @@ public:
|
||||||
|
|
||||||
using DeviceDescriptionPtr = std::shared_ptr<DeviceDescription>;
|
using DeviceDescriptionPtr = std::shared_ptr<DeviceDescription>;
|
||||||
|
|
||||||
|
enum AudioType
|
||||||
|
{
|
||||||
|
TV = 0,
|
||||||
|
Gamepad,
|
||||||
|
Portal
|
||||||
|
};
|
||||||
|
|
||||||
enum AudioAPI
|
enum AudioAPI
|
||||||
{
|
{
|
||||||
DirectSound = 0,
|
DirectSound = 0,
|
||||||
|
@ -62,8 +71,8 @@ public:
|
||||||
static void InitializeStatic();
|
static void InitializeStatic();
|
||||||
static bool IsAudioAPIAvailable(AudioAPI api);
|
static bool IsAudioAPIAvailable(AudioAPI api);
|
||||||
|
|
||||||
static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(bool TV, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample);
|
static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(AudioType type, sint32 rate, sint32 samples_per_block, sint32 bits_per_sample);
|
||||||
static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(bool TV, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample);
|
static std::unique_ptr<IAudioAPI> CreateDeviceFromConfig(AudioType type, sint32 rate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample);
|
||||||
static std::unique_ptr<IAudioAPI> CreateDevice(AudioAPI api, const DeviceDescriptionPtr& device, sint32 samplerate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample);
|
static std::unique_ptr<IAudioAPI> CreateDevice(AudioAPI api, const DeviceDescriptionPtr& device, sint32 samplerate, sint32 channels, sint32 samples_per_block, sint32 bits_per_sample);
|
||||||
static std::vector<DeviceDescriptionPtr> GetDevices(AudioAPI api);
|
static std::vector<DeviceDescriptionPtr> GetDevices(AudioAPI api);
|
||||||
|
|
||||||
|
@ -84,6 +93,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
static uint32 s_audioDelay;
|
static uint32 s_audioDelay;
|
||||||
void InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample);
|
void InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample);
|
||||||
|
static AudioChannels AudioTypeToChannels(AudioType type);
|
||||||
|
static std::wstring GetDeviceFromType(AudioType type);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -479,9 +479,9 @@ struct CemuConfig
|
||||||
// audio
|
// audio
|
||||||
sint32 audio_api = 0;
|
sint32 audio_api = 0;
|
||||||
sint32 audio_delay = 2;
|
sint32 audio_delay = 2;
|
||||||
AudioChannels tv_channels = kStereo, pad_channels = kStereo, input_channels = kMono;
|
AudioChannels tv_channels = kStereo, pad_channels = kStereo, input_channels = kMono, portal_channels = kMono;
|
||||||
sint32 tv_volume = 50, pad_volume = 0, input_volume = 50;
|
sint32 tv_volume = 50, pad_volume = 0, input_volume = 50, portal_volume = 50;
|
||||||
std::wstring tv_device{ L"default" }, pad_device, input_device;
|
std::wstring tv_device{ L"default" }, pad_device, input_device, portal_device;
|
||||||
|
|
||||||
// account
|
// account
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -542,6 +542,47 @@ wxPanel* GeneralSettings2::AddAudioPage(wxNotebook* notebook)
|
||||||
audio_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5);
|
audio_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto box = new wxStaticBox(audio_panel, wxID_ANY, _("Trap Team Portal"));
|
||||||
|
auto box_sizer = new wxStaticBoxSizer(box, wxVERTICAL);
|
||||||
|
|
||||||
|
auto portal_audio_row = new wxFlexGridSizer(0, 3, 0, 0);
|
||||||
|
portal_audio_row->SetFlexibleDirection(wxBOTH);
|
||||||
|
portal_audio_row->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||||
|
|
||||||
|
portal_audio_row->Add(new wxStaticText(box, wxID_ANY, _("Device")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
|
||||||
|
m_portal_device = new wxChoice(box, wxID_ANY, wxDefaultPosition);
|
||||||
|
m_portal_device->SetMinSize(wxSize(300, -1));
|
||||||
|
m_portal_device->SetToolTip(_("Select the active audio output device for Wii U GamePad"));
|
||||||
|
portal_audio_row->Add(m_portal_device, 0, wxEXPAND | wxALL, 5);
|
||||||
|
portal_audio_row->AddSpacer(0);
|
||||||
|
|
||||||
|
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);
|
||||||
|
auto audio_pad_volume_text = new wxStaticText(box, wxID_ANY, "100%");
|
||||||
|
portal_audio_row->Add(audio_pad_volume_text, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxALIGN_RIGHT, 5);
|
||||||
|
|
||||||
|
m_portal_volume->Bind(wxEVT_SLIDER, &GeneralSettings2::OnSliderChangedPercent, this, wxID_ANY, wxID_ANY, new wxControlObject(audio_pad_volume_text));
|
||||||
|
m_portal_volume->Bind(wxEVT_SLIDER, &GeneralSettings2::OnVolumeChanged, this);
|
||||||
|
|
||||||
|
box_sizer->Add(portal_audio_row, 1, wxEXPAND, 5);
|
||||||
|
audio_panel_sizer->Add(box_sizer, 0, wxEXPAND | wxALL, 5);
|
||||||
|
}
|
||||||
|
|
||||||
audio_panel->SetSizerAndFit(audio_panel_sizer);
|
audio_panel->SetSizerAndFit(audio_panel_sizer);
|
||||||
return audio_panel;
|
return audio_panel;
|
||||||
}
|
}
|
||||||
|
@ -989,10 +1030,12 @@ void GeneralSettings2::StoreConfig()
|
||||||
config.pad_channels = kStereo; // (AudioChannels)m_pad_channels->GetSelection();
|
config.pad_channels = kStereo; // (AudioChannels)m_pad_channels->GetSelection();
|
||||||
//config.input_channels = (AudioChannels)m_input_channels->GetSelection();
|
//config.input_channels = (AudioChannels)m_input_channels->GetSelection();
|
||||||
config.input_channels = kMono; // (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.tv_volume = m_tv_volume->GetValue();
|
||||||
config.pad_volume = m_pad_volume->GetValue();
|
config.pad_volume = m_pad_volume->GetValue();
|
||||||
config.input_volume = m_input_volume->GetValue();
|
config.input_volume = m_input_volume->GetValue();
|
||||||
|
config.portal_volume = m_portal_volume->GetValue();
|
||||||
|
|
||||||
config.tv_device.clear();
|
config.tv_device.clear();
|
||||||
const auto tv_device = m_tv_device->GetSelection();
|
const auto tv_device = m_tv_device->GetSelection();
|
||||||
|
@ -1021,6 +1064,15 @@ void GeneralSettings2::StoreConfig()
|
||||||
config.input_device = device_description->GetDescription()->GetIdentifier();
|
config.input_device = device_description->GetDescription()->GetIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.portal_device.clear();
|
||||||
|
const auto portal_device = m_portal_device->GetSelection();
|
||||||
|
if (portal_device != wxNOT_FOUND && portal_device != 0 && m_portal_device->HasClientObjectData())
|
||||||
|
{
|
||||||
|
const auto* device_description = (wxDeviceDescription*)m_portal_device->GetClientObject(portal_device);
|
||||||
|
if (device_description)
|
||||||
|
config.portal_device = device_description->GetDescription()->GetIdentifier();
|
||||||
|
}
|
||||||
|
|
||||||
// graphics
|
// graphics
|
||||||
config.graphic_api = (GraphicAPI)m_graphic_api->GetSelection();
|
config.graphic_api = (GraphicAPI)m_graphic_api->GetSelection();
|
||||||
|
|
||||||
|
@ -1195,10 +1247,12 @@ void GeneralSettings2::UpdateAudioDeviceList()
|
||||||
m_tv_device->Clear();
|
m_tv_device->Clear();
|
||||||
m_pad_device->Clear();
|
m_pad_device->Clear();
|
||||||
m_input_device->Clear();
|
m_input_device->Clear();
|
||||||
|
m_portal_device->Clear();
|
||||||
|
|
||||||
m_tv_device->Append(_("Disabled"));
|
m_tv_device->Append(_("Disabled"));
|
||||||
m_pad_device->Append(_("Disabled"));
|
m_pad_device->Append(_("Disabled"));
|
||||||
m_input_device->Append(_("Disabled"));
|
m_input_device->Append(_("Disabled"));
|
||||||
|
m_portal_device->Append(_("Disabled"));
|
||||||
|
|
||||||
const auto audio_api = (IAudioAPI::AudioAPI)GetConfig().audio_api;
|
const auto audio_api = (IAudioAPI::AudioAPI)GetConfig().audio_api;
|
||||||
const auto devices = IAudioAPI::GetDevices(audio_api);
|
const auto devices = IAudioAPI::GetDevices(audio_api);
|
||||||
|
@ -1206,6 +1260,7 @@ void GeneralSettings2::UpdateAudioDeviceList()
|
||||||
{
|
{
|
||||||
m_tv_device->Append(device->GetName(), new wxDeviceDescription(device));
|
m_tv_device->Append(device->GetName(), new wxDeviceDescription(device));
|
||||||
m_pad_device->Append(device->GetName(), new wxDeviceDescription(device));
|
m_pad_device->Append(device->GetName(), new wxDeviceDescription(device));
|
||||||
|
m_portal_device->Append(device->GetName(), new wxDeviceDescription(device));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto input_audio_api = IAudioInputAPI::Cubeb; //(IAudioAPI::AudioAPI)GetConfig().input_audio_api;
|
const auto input_audio_api = IAudioInputAPI::Cubeb; //(IAudioAPI::AudioAPI)GetConfig().input_audio_api;
|
||||||
|
@ -1225,6 +1280,8 @@ void GeneralSettings2::UpdateAudioDeviceList()
|
||||||
|
|
||||||
m_input_device->SetSelection(0);
|
m_input_device->SetSelection(0);
|
||||||
|
|
||||||
|
m_portal_device->SetSelection(0);
|
||||||
|
|
||||||
// todo reset global instance of audio device
|
// todo reset global instance of audio device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1658,6 +1715,7 @@ void GeneralSettings2::ApplyConfig()
|
||||||
m_pad_channels->SetSelection(0);
|
m_pad_channels->SetSelection(0);
|
||||||
//m_input_channels->SetSelection(config.pad_channels);
|
//m_input_channels->SetSelection(config.pad_channels);
|
||||||
m_input_channels->SetSelection(0);
|
m_input_channels->SetSelection(0);
|
||||||
|
m_portal_channels->SetSelection(0);
|
||||||
|
|
||||||
SendSliderEvent(m_tv_volume, config.tv_volume);
|
SendSliderEvent(m_tv_volume, config.tv_volume);
|
||||||
|
|
||||||
|
@ -1708,6 +1766,22 @@ void GeneralSettings2::ApplyConfig()
|
||||||
else
|
else
|
||||||
m_input_device->SetSelection(0);
|
m_input_device->SetSelection(0);
|
||||||
|
|
||||||
|
SendSliderEvent(m_portal_volume, config.portal_volume);
|
||||||
|
if (!config.portal_device.empty() && m_portal_device->HasClientObjectData())
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < m_portal_device->GetCount(); ++i)
|
||||||
|
{
|
||||||
|
const auto device_description = (wxDeviceDescription*)m_portal_device->GetClientObject(i);
|
||||||
|
if (device_description && config.portal_device == device_description->GetDescription()->GetIdentifier())
|
||||||
|
{
|
||||||
|
m_portal_device->SetSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_portal_device->SetSelection(0);
|
||||||
|
|
||||||
// account
|
// account
|
||||||
UpdateOnlineAccounts();
|
UpdateOnlineAccounts();
|
||||||
m_active_account->SetSelection(0);
|
m_active_account->SetSelection(0);
|
||||||
|
@ -1866,6 +1940,42 @@ void GeneralSettings2::UpdateAudioDevice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// skylander portal audio device
|
||||||
|
{
|
||||||
|
const auto selection = m_portal_device->GetSelection();
|
||||||
|
if (selection == wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
cemu_assert_debug(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_portalAudio.reset();
|
||||||
|
|
||||||
|
if (m_portal_device->HasClientObjectData())
|
||||||
|
{
|
||||||
|
const auto description = (wxDeviceDescription*)m_portal_device->GetClientObject(selection);
|
||||||
|
if (description)
|
||||||
|
{
|
||||||
|
sint32 channels;
|
||||||
|
if (m_game_launched && g_portalAudio)
|
||||||
|
channels = g_portalAudio->GetChannels();
|
||||||
|
else
|
||||||
|
channels = 1;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
g_portalAudio = IAudioAPI::CreateDevice((IAudioAPI::AudioAPI)config.audio_api, description->GetDescription(), 8000, 1, 32, 16);
|
||||||
|
g_portalAudio->SetVolume(m_portal_volume->GetValue());
|
||||||
|
}
|
||||||
|
catch (std::runtime_error& ex)
|
||||||
|
{
|
||||||
|
cemuLog_log(LogType::Force, "can't initialize pad audio: {}", ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralSettings2::OnAudioDeviceSelected(wxCommandEvent& event)
|
void GeneralSettings2::OnAudioDeviceSelected(wxCommandEvent& event)
|
||||||
|
@ -1895,6 +2005,13 @@ void GeneralSettings2::OnAudioChannelsSelected(wxCommandEvent& event)
|
||||||
|
|
||||||
config.pad_channels = (AudioChannels)obj->GetSelection();
|
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
|
else
|
||||||
cemu_assert_debug(false);
|
cemu_assert_debug(false);
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ private:
|
||||||
// Audio
|
// Audio
|
||||||
wxChoice* m_audio_api;
|
wxChoice* m_audio_api;
|
||||||
wxSlider *m_audio_latency;
|
wxSlider *m_audio_latency;
|
||||||
wxSlider *m_tv_volume, *m_pad_volume, *m_input_volume;
|
wxSlider *m_tv_volume, *m_pad_volume, *m_input_volume, *m_portal_volume;
|
||||||
wxChoice *m_tv_channels, *m_pad_channels, *m_input_channels;
|
wxChoice *m_tv_channels, *m_pad_channels, *m_input_channels, *m_portal_channels;
|
||||||
wxChoice *m_tv_device, *m_pad_device, *m_input_device;
|
wxChoice *m_tv_device, *m_pad_device, *m_input_device, *m_portal_device;
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
wxButton* m_create_account, * m_delete_account;
|
wxButton* m_create_account, * m_delete_account;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue