Skip to content

Commit

Permalink
OGG: Fixed wrong byte order when resampling to 16 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
RaZeR-RBI committed Jan 23, 2024
1 parent 10f6029 commit 827fd9d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Vox/Decoders/Ogg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static void LoadFromOgg(this SoundBuffer buffer, Stream stream,
if (closeStream) stream.Close();
}

private static void ResampleToPCM(float[] src, byte[] dst, int srcCount,
public static void ResampleToPCM(Span<float> src, Span<byte> dst, int srcCount,
SampleQuality quality, int srcIndex = 0, int dstIndex = 0)
{
for (var i = 0; i < srcCount; i++)
Expand All @@ -135,13 +135,13 @@ private static void ResampleToPCM(float[] src, byte[] dst, int srcCount,
var byte2 = (byte) (sample & 255);
if (BitConverter.IsLittleEndian)
{
dst[i * 2 + dstIndex] = byte1;
dst[i * 2 + dstIndex + 1] = byte2;
dst[i * 2 + dstIndex] = byte2;
dst[i * 2 + dstIndex + 1] = byte1;
}
else
{
dst[i * 2 + dstIndex] = byte2;
dst[i * 2 + dstIndex + 1] = byte1;
dst[i * 2 + dstIndex] = byte1;
dst[i * 2 + dstIndex + 1] = byte2;
}

break;
Expand Down

0 comments on commit 827fd9d

Please sign in to comment.