Route the wiimote speaker to the sound mixer (the host system's speakers). Emulated Wiimote speaker sounds will go to the host system's speakers. Real Wiimotes will continue to use their own speaker for Wiimote speaker sounds. All Wiimote speaker sound can be disabled by unchecking the "Enable Speaker Data" option.

Each emulated Wiimote can have its speaker routed from left to right via the "Speaker Pan" setting in the emulated wiimote settings dialog.  Use any value from -127 for leftmost to 127 for rightmost with 0 being the centre.

Added code in the InputConfig to use a spin control for non-boolean values.

Defaulted the setting of "Enable Speaker Data" to disabled.
This commit is contained in:
skidau 2014-09-06 01:23:54 +10:00
parent 3caab10df8
commit 8abe9622fd
6 changed files with 38 additions and 24 deletions

View File

@ -168,7 +168,7 @@ void CMixer::PushStreamingSamples(const short *samples, unsigned int num_samples
m_streaming_mixer.PushSamples(samples, num_samples); m_streaming_mixer.PushSamples(samples, num_samples);
} }
void CMixer::PushWiimoteSpeakerSamples(const short *samples, unsigned int num_samples, unsigned int sample_rate, const u8 wiimote_index) void CMixer::PushWiimoteSpeakerSamples(const short *samples, unsigned int num_samples, unsigned int sample_rate)
{ {
short samples_stereo[MAX_SAMPLES * 2]; short samples_stereo[MAX_SAMPLES * 2];
@ -178,14 +178,7 @@ void CMixer::PushWiimoteSpeakerSamples(const short *samples, unsigned int num_sa
for (unsigned int i = 0; i < num_samples; ++i) for (unsigned int i = 0; i < num_samples; ++i)
{ {
// Position the Wiimotes as follow
// Wiimote 0 = Center
// Wiimote 1 = Left
// Wiimote 2 = Right
// Wiimote 3 = Center
if (wiimote_index != 2)
samples_stereo[i * 2] = Common::swap16(samples[i]); samples_stereo[i * 2] = Common::swap16(samples[i]);
if (wiimote_index != 1)
samples_stereo[i * 2 + 1] = Common::swap16(samples[i]); samples_stereo[i * 2 + 1] = Common::swap16(samples[i]);
} }

View File

@ -40,7 +40,7 @@ public:
// Called from main thread // Called from main thread
virtual void PushSamples(const short* samples, unsigned int num_samples); virtual void PushSamples(const short* samples, unsigned int num_samples);
virtual void PushStreamingSamples(const short* samples, unsigned int num_samples); virtual void PushStreamingSamples(const short* samples, unsigned int num_samples);
virtual void PushWiimoteSpeakerSamples(const short* samples, unsigned int num_samples, unsigned int sample_rate, const u8 wiimote_index); virtual void PushWiimoteSpeakerSamples(const short* samples, unsigned int num_samples, unsigned int sample_rate);
unsigned int GetSampleRate() const { return m_sampleRate; } unsigned int GetSampleRate() const { return m_sampleRate; }
void SetDMAInputSampleRate(unsigned int rate); void SetDMAInputSampleRate(unsigned int rate);

View File

@ -521,7 +521,7 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("WiiSDCard", &m_WiiSDCard, false); core->Get("WiiSDCard", &m_WiiSDCard, false);
core->Get("WiiKeyboard", &m_WiiKeyboard, false); core->Get("WiiKeyboard", &m_WiiKeyboard, false);
core->Get("WiimoteContinuousScanning", &m_WiimoteContinuousScanning, false); core->Get("WiimoteContinuousScanning", &m_WiimoteContinuousScanning, false);
core->Get("WiimoteEnableSpeaker", &m_WiimoteEnableSpeaker, true); core->Get("WiimoteEnableSpeaker", &m_WiimoteEnableSpeaker, false);
core->Get("RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false); core->Get("RunCompareServer", &m_LocalCoreStartupParameter.bRunCompareServer, false);
core->Get("RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false); core->Get("RunCompareClient", &m_LocalCoreStartupParameter.bRunCompareClient, false);
core->Get("MMU", &m_LocalCoreStartupParameter.bMMU, false); core->Get("MMU", &m_LocalCoreStartupParameter.bMMU, false);

View File

@ -78,8 +78,12 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
{ {
samples[i] = (s16)(s8)sd->data[i]; samples[i] = (s16)(s8)sd->data[i];
} }
soundStream->GetMixer()->SetWiimoteSpeakerVolume(256, 256);
soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 1500, m_index); // Speaker Pan
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
soundStream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);
soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 1500);
} }
else if (m_reg_speaker.format == 0x00) else if (m_reg_speaker.format == 0x00)
{ {
@ -89,8 +93,12 @@ void Wiimote::SpeakerData(wm_speaker_data* sd)
samples[i * 2] = adpcm_yamaha_expand_nibble(m_adpcm_state, (sd->data[i] >> 4) & 0xf); samples[i * 2] = adpcm_yamaha_expand_nibble(m_adpcm_state, (sd->data[i] >> 4) & 0xf);
samples[i * 2 + 1] = adpcm_yamaha_expand_nibble(m_adpcm_state, sd->data[i] & 0xf); samples[i * 2 + 1] = adpcm_yamaha_expand_nibble(m_adpcm_state, sd->data[i] & 0xf);
} }
soundStream->GetMixer()->SetWiimoteSpeakerVolume(256, 256);
soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 3000, m_index); // Speaker Pan
unsigned int vol = (unsigned int)(m_options->settings[4]->GetValue() * 100);
soundStream->GetMixer()->SetWiimoteSpeakerVolume(128 + vol, 128 - vol);
soundStream->GetMixer()->PushWiimoteSpeakerSamples(samples, sd->length, 3000);
} }
#ifdef WIIMOTE_SPEAKER_DUMP #ifdef WIIMOTE_SPEAKER_DUMP

View File

@ -309,6 +309,7 @@ Wiimote::Wiimote( const unsigned int index )
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false)); m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Sideways Wiimote"), false));
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false)); m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Upright Wiimote"), false));
m_options->settings.emplace_back(new ControlGroup::IterateUI(_trans("Iterative Input"))); m_options->settings.emplace_back(new ControlGroup::IterateUI(_trans("Iterative Input")));
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Speaker Pan"), 0, -127, 127));
// TODO: This value should probably be re-read if SYSCONF gets changed // TODO: This value should probably be re-read if SYSCONF gets changed
m_sensor_bar_on_top = SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR") != 0; m_sensor_bar_on_top = SConfig::GetInstance().m_SYSCONF->GetData<u8>("BT.BAR") != 0;

View File

@ -910,6 +910,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
{ {
//options //options
for (auto& groupSetting : group->settings) for (auto& groupSetting : group->settings)
{
if (groupSetting.get()->high == 100)
{ {
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get()); PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get());
if (groupSetting.get()->is_iterate == true) if (groupSetting.get()->is_iterate == true)
@ -922,9 +924,19 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink); setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustSetting, eventsink);
} }
options.push_back(setting_cbox); options.push_back(setting_cbox);
Add(setting_cbox->wxcontrol, 0, wxALL | wxLEFT, 5); Add(setting_cbox->wxcontrol, 0, wxALL | wxLEFT, 5);
} }
else
{
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(new wxStaticText(parent, -1, wxGetTranslation(StrToWxStr(groupSetting->name))), 0, wxCENTER | wxRIGHT, 3);
szr->Add(setting->wxcontrol, 0, wxRIGHT, 3);
Add(szr, 0, wxALL | wxCENTER, 3);
}
}
} }
break; break;
} }