Key ideas:
- Sound is necessarily temporal. You can drop a frame of video and the user probably won't notice, but if your audio drops out, they probably will notice.
- Sound bufers are small, and not all platforms will require us to deal with circular buffers. So one option is to do a buffer copy per frame and present the game with a contiguous block of memory. This should be cheap enough.
- Much like the bitmap, allocate plenty of space for a sound buffer at startup, and reuse it each frame.
C features
alloca
alloca
is a compiler feature that allows for dynamic allocation on the stack. Much was learned and discussed, but
it should be noted that the function is deprecated and probably shouldn't be used in shipping code.