I'm not sure if this has been addressed already but I'm pretty sure there's a buffer over-read in the audio blending code.


1
2
3
4
5
6
u32 SampleIndex = FloorReal32ToInt32(SamplePosition);

r32 Frac = SamplePosition - (r32)SampleIndex;
r32 Sample0 = (r32)LoadedSound->Samples[0][SampleIndex];
r32 Sample1 = (r32)LoadedSound->Samples[0][SampleIndex + 1];
r32 SampleValue = Lerp(Sample0, Frac, Sample1);


When SampleIndex is on the last sample in the clip it tries to read from Samples[0][Samples + 1] which is out of bounds of the array, right? I'm guessing the best way to fix this would be to add some padding samples to the end of the clip, like you would a texture?

Also in my own audio mixer I fixed the precision issues with SamplePosition by storing it in two separate values (a u32 for the integer part and an f32 for the fractional part). Casey, I'd be interested to hear if you plan to do something similar.

P.S Thank you so much for Handmade Hero!! :)