From 3c2a33b70a15aec53c876a239607e2b02609e7c1 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 8 Oct 2025 04:16:40 +0200 Subject: [PATCH] wavcodec: fix WAV file loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Read samples from “first sample byte” to “first sample byte + size” instead of reading from “first sample byte” to “first header byte + size”. It means we now: - don't wrongfully truncate the end of the file from the size of the header, - can load files with less samples than the header size. --- src/engine/audio/WavCodec.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/audio/WavCodec.cpp b/src/engine/audio/WavCodec.cpp index 45332e3199..921aaf707b 100644 --- a/src/engine/audio/WavCodec.cpp +++ b/src/engine/audio/WavCodec.cpp @@ -114,7 +114,8 @@ AudioData LoadWavCodec(std::string filename) } AudioData out { sampleRate, byteDepth, numChannels }; - out.rawSamples.assign( audioFile.data() + dataOffset + 8, audioFile.data() + size ); + auto firstSample = audioFile.data() + dataOffset + 8; + out.rawSamples.assign( firstSample, firstSample + size ); return out; }