Read and write simultaneously from a .wav file?


Is it possible to read and write simultaneously from a .wav file? I'm writing a looper, and my plan was to use AudioFormatWriter::ThreadedWriter to write the current audio data to a .wav file (one .wav file per "take", regardless of how many play/record loops there are on the track), and separately to create a MemoryMappedAudioFormatReader for each playback loop on the track, reading from the appropriate position in the "take" .wav file at the appropriate time.

I tried implementing this, but I WavAudioFormat::createMemoryMappedReader() fails, returning null instead of a valid reader.



I would do this all in memory and save later, when there is something to save.

Like, keep a 'new' and an 'old' loop buffer...then whenever it starts over, add the new to the old, clear the new, and start again.

Reading and writing to the same file is not going to be pretty.


Hope that helps.

Turntable is right, writing to disk is slow. Circular buffers are you friend. 

Circular buffers are you friend. 

...and so is the friendly modulo (%)!!!!

Rory, turntable: thanks a lot for your advice!