diff --git a/RedBookPlayer.Common/Hardware/SoundOutput.cs b/RedBookPlayer.Common/Hardware/SoundOutput.cs index 5d78791..8531775 100644 --- a/RedBookPlayer.Common/Hardware/SoundOutput.cs +++ b/RedBookPlayer.Common/Hardware/SoundOutput.cs @@ -236,20 +236,7 @@ namespace RedBookPlayer.Common.Hardware // Apply de-emphasis filtering, only if enabled if(ApplyDeEmphasis) - { - float[][] floatAudioData = new float[2][]; - floatAudioData[0] = new float[audioDataSegment.Length / 4]; - floatAudioData[1] = new float[audioDataSegment.Length / 4]; - ByteConverter.ToFloats16Bit(audioDataSegment, floatAudioData); - - for(int i = 0; i < floatAudioData[0].Length; i++) - { - floatAudioData[0][i] = _deEmphasisFilterLeft.Process(floatAudioData[0][i]); - floatAudioData[1][i] = _deEmphasisFilterRight.Process(floatAudioData[1][i]); - } - - ByteConverter.FromFloats16Bit(floatAudioData, audioDataSegment); - } + ProcessDeEmphasis(audioDataSegment); // Write out the audio data to the buffer Array.Copy(audioDataSegment, 0, buffer, offset, count); @@ -316,6 +303,26 @@ namespace RedBookPlayer.Common.Hardware /// New volume value public void SetVolume(int volume) => Volume = volume; + /// + /// Process de-emphasis of audio data + /// + /// Audio data to process + private void ProcessDeEmphasis(byte[] audioData) + { + float[][] floatAudioData = new float[2][]; + floatAudioData[0] = new float[audioData.Length / 4]; + floatAudioData[1] = new float[audioData.Length / 4]; + ByteConverter.ToFloats16Bit(audioData, floatAudioData); + + for(int i = 0; i < floatAudioData[0].Length; i++) + { + floatAudioData[0][i] = _deEmphasisFilterLeft.Process(floatAudioData[0][i]); + floatAudioData[1][i] = _deEmphasisFilterRight.Process(floatAudioData[1][i]); + } + + ByteConverter.FromFloats16Bit(floatAudioData, audioData); + } + /// /// Sets or resets the de-emphasis filters ///