Streaming Audio Update


The latest PegPuzzle versions for D3D11 and D3D12 feature streaming background music as well as some other updates to reduce memory. The approach I took for audio streaming was to have two buffers that can contain one seconds worth of audio data. I move through the background music file reading one seconds worth of data on a separate thread and ping pong between the two buffers. One buffer is being read by XAudio2 and the other is having file data written to it. It was pretty cool to get it working; however, I also spent a lot of time testing and fixing various edge cases. In particular, I needed to make sure that what I implemented was tolerant of failed file reads, short file reads (less data was returned than was requested), and longer than expected file reads. If you're interested in learning more about streaming audio, you can check out:

  1. https://docs.microsoft.com/en-us/windows/win32/xaudio2/how-to--stream-a-sound-from-disk
  2. https://bell0bytes.eu/streaming-music-with-xaudio2/

If you have any questions, feel free to leave a comment.

Get Peg Puzzle

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.