diff options
| author | Adam D. Moss <c@yotes.com> | 2015-01-18 23:11:45 +0000 |
|---|---|---|
| committer | Adam D. Moss <c@yotes.com> | 2015-01-19 10:24:44 +0000 |
| commit | 05d2bf6060e26d3507bbb6f285c452a328101780 (patch) | |
| tree | 7041dd696a6e307f918c83c03abc82d6bc5b7d4d /Source/Core/AudioCommon/PulseAudioStream.cpp | |
| parent | 37a770bb9f23404cbdc75e8cc2df31dfecb97057 (diff) | |
Audio: Drop the LFE/subwoofer channel from the decoded surround
DPL2Decode still doesn't decode 5.1 properly, leaving bass in all channels, but its 5.0 is pretty good, so leave it at that.
Diffstat (limited to 'Source/Core/AudioCommon/PulseAudioStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/PulseAudioStream.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/PulseAudioStream.cpp b/Source/Core/AudioCommon/PulseAudioStream.cpp index e474fdf14d..8f36286403 100644 --- a/Source/Core/AudioCommon/PulseAudioStream.cpp +++ b/Source/Core/AudioCommon/PulseAudioStream.cpp @@ -23,7 +23,7 @@ PulseAudio::PulseAudio(CMixer *mixer) bool PulseAudio::Start() { m_stereo = !SConfig::GetInstance().m_LocalCoreStartupParameter.bDPL2Decoder; - m_channels = m_stereo ? 2 : 6; // will tell PA we use a Stereo or 5.1 channel setup + m_channels = m_stereo ? 2 : 5; // will tell PA we use a Stereo or 5.0 channel setup NOTICE_LOG(AUDIO, "PulseAudio backend using %d channels", m_channels); @@ -103,15 +103,13 @@ bool PulseAudio::PulseInit() ss.format = PA_SAMPLE_FLOAT32NE; m_bytespersample = sizeof(float); - // DPL2Decode output: LEFTFRONT, RIGHTFRONT, CENTREFRONT, (sub), LEFTREAR, RIGHTREAR channel_map_p = &channel_map; // explicit channel map: - channel_map.channels = 6; + channel_map.channels = 5; channel_map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; channel_map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; channel_map.map[2] = PA_CHANNEL_POSITION_FRONT_CENTER; - channel_map.map[3] = PA_CHANNEL_POSITION_LFE; - channel_map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT; - channel_map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT; + channel_map.map[3] = PA_CHANNEL_POSITION_REAR_LEFT; + channel_map.map[4] = PA_CHANNEL_POSITION_REAR_RIGHT; } ss.channels = m_channels; ss.rate = m_mixer->GetSampleRate(); @@ -202,9 +200,22 @@ void PulseAudio::WriteCallback(pa_stream* s, size_t length) floatbuffer_stereo[i] = s16buffer_stereo[i] / float(1 << 15); } - if (m_channels == 6) // Extract dpl2/5.1 Surround + if (m_channels == 5) // Extract dpl2/5.0 Surround { - DPL2Decode(floatbuffer_stereo, frames, (float*)buffer); + float floatbuffer_6chan[frames * 6]; + // DPL2Decode output: LEFTFRONT, RIGHTFRONT, CENTREFRONT, (sub), LEFTREAR, RIGHTREAR + DPL2Decode(floatbuffer_stereo, frames, floatbuffer_6chan); + + // Discard the subwoofer channel - DPL2Decode generates a pretty + // good 5.0 but not a good 5.1 output. + const int dpl2_to_5chan[] = {0,1,2,4,5}; + for (int i=0; i < frames; ++i) + { + for (int j=0; j < m_channels; ++j) + { + ((float*)buffer)[m_channels * i + j] = floatbuffer_6chan[6 * i + dpl2_to_5chan[j]]; + } + } } else { |
