Register
Handmade Hero»Forums»Code»Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
Benjamin Pedersen
24 posts

Mathematician

Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
3 years, 7 months ago Edited by Benjamin Pedersen on Oct. 29, 2016, 3:38 p.m.
I was thinking:
We know approximately how much we want to write to the sound buffer each frame and we can afford to write a safety margin. Couldn't we get our audio latency down a bit by calling Game.GetSoundSamples before GetCurrentPosition? Or is it not worth it?
39 posts
Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
3 years, 6 months ago
I don't know, but maybe you could try it and see if you can see a difference in latency.

The audio system is planned to be cleaned up and debugged later in the series.
Simon Anciaux
791 posts
Writing audio to game_sound_output_buffer before polling PlayCursor / WriteCursor
3 years, 6 months ago
Since windows Vista, DirectSound isn't hardware accelerated, it's software emulated and goes through the kernel mixer. You can find some informations on msdn and wikipedia.

For what I remember, the difference between the write cursor and the play cursor is the minimum latency you can achieve and it's about 30ms. And the minimum change in the cursor position is 1/100s worth of samples.

And calling GetCurrentPositon later would not help, since you still need to write samples between the last write and what is expected to be the next write.