Those of you who’ve written a DAW … what was your strategy for recording audio? It’d be convenient to allocate a huge chunk of memory and just write straight from the audio thread but this would assume infinite memory, limited recording length and risks data lose if there’s a crash.
- FIFO the data out of the audio thread through a buffer that’ll hold a few seconds of audio
- Copy it to a pre-write buffer that I expand on the heap as required pre-writing to disk
- Swap the pre-write buffer for a new one and write the old one to disk every five or six seconds
This allows for the disk access to be delay by any amount, and allows the size of the FIFO buffer for memory allocation (and possibly copying of data) to complete.
Or maybe it’s easier to go with just the FIFO and make it bigger…