From 3caab10df8eaaa79ced782befb0b84a98721136d Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 5 Sep 2014 22:32:48 +1000 Subject: Hooked up the emulated Wiimote speaker. The Wiimotes are positioned as follows: Wiimote 0 = Center Wiimote 1 = Left Wiimote 2 = Right Wiimote 3 = Center The Wiimote speaker output can be disabled via the "Enable Speaker Data" checkbox in the Wiimote settings. --- Source/Core/AudioCommon/Mixer.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Source/Core/AudioCommon/Mixer.cpp') diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index 70accf240f..0a71fbd98b 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -121,6 +121,7 @@ unsigned int CMixer::Mix(short* samples, unsigned int num_samples, bool consider m_dma_mixer.Mix(samples, num_samples, consider_framelimit); m_streaming_mixer.Mix(samples, num_samples, consider_framelimit); + m_wiimote_speaker_mixer.Mix(samples, num_samples, consider_framelimit); if (m_logAudio) g_wave_writer.AddStereoSamples(samples, num_samples); return num_samples; @@ -167,6 +168,31 @@ void CMixer::PushStreamingSamples(const short *samples, unsigned int 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) +{ + short samples_stereo[MAX_SAMPLES * 2]; + + if (num_samples < MAX_SAMPLES) + { + m_wiimote_speaker_mixer.SetInputSampleRate(sample_rate); + + 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]); + if (wiimote_index != 1) + samples_stereo[i * 2 + 1] = Common::swap16(samples[i]); + } + + m_wiimote_speaker_mixer.PushSamples(samples_stereo, num_samples); + } +} + void CMixer::SetDMAInputSampleRate(unsigned int rate) { m_dma_mixer.SetInputSampleRate(rate); @@ -182,6 +208,11 @@ void CMixer::SetStreamingVolume(unsigned int lvolume, unsigned int rvolume) m_streaming_mixer.SetVolume(lvolume, rvolume); } +void CMixer::SetWiimoteSpeakerVolume(unsigned int lvolume, unsigned int rvolume) +{ + m_wiimote_speaker_mixer.SetVolume(lvolume, rvolume); +} + void CMixer::MixerFifo::SetInputSampleRate(unsigned int rate) { m_input_sample_rate = rate; -- cgit v1.2.3 From 8abe9622fd125f86e95d1ba62f6f2b16ff93791f Mon Sep 17 00:00:00 2001 From: skidau Date: Sat, 6 Sep 2014 01:23:54 +1000 Subject: 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. --- Source/Core/AudioCommon/Mixer.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'Source/Core/AudioCommon/Mixer.cpp') diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index 0a71fbd98b..a7984579ca 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -168,7 +168,7 @@ void CMixer::PushStreamingSamples(const short *samples, unsigned int 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]; @@ -178,15 +178,8 @@ void CMixer::PushWiimoteSpeakerSamples(const short *samples, unsigned int num_sa 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]); - if (wiimote_index != 1) - samples_stereo[i * 2 + 1] = Common::swap16(samples[i]); + samples_stereo[i * 2] = Common::swap16(samples[i]); + samples_stereo[i * 2 + 1] = Common::swap16(samples[i]); } m_wiimote_speaker_mixer.PushSamples(samples_stereo, num_samples); -- cgit v1.2.3