Handmade Hero»Forums»Code
Dejan
25 posts
Audio Code
That was a great stream about audio syncing.

With the very last modification done, the ExpectedFrameBoundaryByte wasn't updated to the better value.

The very last line in this code block:

1
2
3
4
5
6
DWORD ExpectedSoundBytesPerFrame = (SoundOutput.SamplesPerSecond*SoundOutput.BytesPerSample) / GameUpdateHz;
real32 SecondsLeftUntilFlip = (TargetSecondsPerFrame - FromBeginToAudioSeconds);

DWORD ExpectedBytesUntilFlip = (DWORD)((SecondsLeftUntilFlip/TargetSecondsPerFrame)*(real32)ExpectedSoundBytesPerFrame);

DWORD ExpectedFrameBoundaryByte = PlayCursor + ExpectedSoundBytesPerFrame;


What it probably should be:
1
DWORD ExpectedFrameBoundaryByte = PlayCursor + ExpectedBytesUntilFlip;
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Audio Code
Thanks for the catch!!! I hope that improves our problem... unfortunately I have to wait until Monday to find out :(

- Casey