diff --git a/src/Spice86.Core/Emulator/Devices/Sound/SoftwareMixer.cs b/src/Spice86.Core/Emulator/Devices/Sound/SoftwareMixer.cs index 6de46ce8a..55144ea5b 100644 --- a/src/Spice86.Core/Emulator/Devices/Sound/SoftwareMixer.cs +++ b/src/Spice86.Core/Emulator/Devices/Sound/SoftwareMixer.cs @@ -43,15 +43,7 @@ internal int Render(Span data, SoundChannel channel) { Span target = stackalloc float[data.Length]; for (int i = 0; i < data.Length; i++) { - // Apply volume and separation to left channel target[i] = data[i] * finalVolumeFactor; - // Ensure we don't go out of range - if (i + 1 >= data.Length) { - break; - } - // Apply volume and separation to right channel - target[i + 1] = data[i] * finalVolumeFactor; - } return _channels[channel].WriteData(target); } @@ -66,15 +58,8 @@ internal int Render(Span data, SoundChannel channel) { float finalVolumeFactor = volumeFactor * (1 + separation); Span target = stackalloc float[data.Length]; - for (int i = 0; i < data.Length; i += 2) { - // Apply volume and separation to left channel + for (int i = 0; i < data.Length; i++) { target[i] = (data[i] / 32768f) * finalVolumeFactor; - // Ensure we don't go out of range - if (i + 1 >= data.Length) { - break; - } - // Apply volume and separation to right channel - target[i + 1] = (data[i] / 32768f) * finalVolumeFactor; } return _channels[channel].WriteData(target); @@ -90,15 +75,8 @@ internal int Render(Span data, SoundChannel channel) { float finalVolumeFactor = volumeFactor * (1 + separation); Span target = stackalloc float[data.Length]; - for (int i = 0; i < data.Length; i += 2) { - // Apply volume and separation to left channel + for (int i = 0; i < data.Length; i++) { target[i] = ((data[i] - 127) / 128f) * finalVolumeFactor; - // Ensure we don't go out of range - if (i + 1 >= data.Length) { - break; - } - // Apply volume and separation to right channel - target[i + 1] = ((data[i + 1] - 127) / 128f) * finalVolumeFactor; } return _channels[channel].WriteData(target); } @@ -124,4 +102,4 @@ public void Dispose() { public void Accept(T emulatorDebugger) where T : IInternalDebugger { emulatorDebugger.Visit(this); } -} +} \ No newline at end of file