diff options
| author | skidau <skidau@gmail.com> | 2014-09-05 22:32:48 +1000 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2014-09-07 14:16:20 +1000 |
| commit | 3caab10df8eaaa79ced782befb0b84a98721136d (patch) | |
| tree | 02ef31e8be2d4e9dd1852bc441685c52a205b4e6 /Source/Core/AudioCommon | |
| parent | b801c7f8f130284eec0690474a312a45ee6a4964 (diff) | |
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.
Diffstat (limited to 'Source/Core/AudioCommon')
| -rw-r--r-- | Source/Core/AudioCommon/Mixer.cpp | 31 | ||||
| -rw-r--r-- | Source/Core/AudioCommon/Mixer.h | 4 |
2 files changed, 35 insertions, 0 deletions
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; diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index 806e6aa83a..f12066d22f 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -24,6 +24,7 @@ public: CMixer(unsigned int BackendSampleRate) : m_dma_mixer(this, 32000) , m_streaming_mixer(this, 48000) + , m_wiimote_speaker_mixer(this, 3000) , m_sampleRate(BackendSampleRate) , m_logAudio(0) , m_speed(0) @@ -39,11 +40,13 @@ public: // Called from main thread virtual void PushSamples(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); unsigned int GetSampleRate() const { return m_sampleRate; } void SetDMAInputSampleRate(unsigned int rate); void SetStreamInputSampleRate(unsigned int rate); void SetStreamingVolume(unsigned int lvolume, unsigned int rvolume); + void SetWiimoteSpeakerVolume(unsigned int lvolume, unsigned int rvolume); virtual void StartLogAudio(const std::string& filename) { @@ -112,6 +115,7 @@ protected: }; MixerFifo m_dma_mixer; MixerFifo m_streaming_mixer; + MixerFifo m_wiimote_speaker_mixer; unsigned int m_sampleRate; WaveFileWriter g_wave_writer; |
