Skip to content

Commit e636540

Browse files
committed
wavcodec: fix WAV file loading
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.
1 parent fae6ddd commit e636540

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/engine/audio/WavCodec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ AudioData LoadWavCodec(std::string filename)
114114
}
115115

116116
AudioData out { sampleRate, byteDepth, numChannels };
117-
out.rawSamples.assign( audioFile.data() + dataOffset + 8, audioFile.data() + size );
117+
auto firstSample = audioFile.data() + dataOffset + 8;
118+
out.rawSamples.assign( firstSample, firstSample + size );
118119

119120
return out;
120121
}

0 commit comments

Comments
 (0)