How to record properly RAW files


#1

Hello everybody !

For my work, I have to develop a software which can read a WAV file and save into RAW files float 32 bits samples from 8 microphones.

The way I do things is the following : the WAV file is read with a AudioTransportSource class. The record is done using the writeFloat function in each call of the AudioDeviceIOCallback, with a loop on the “numSamples” samples for each channel.

Problem : with a low latency, I have too much cracks, on the file which is played. So, I’d like to know what is the “right” way to do that. Should I play the file in a separate thread ? Should I access to the disk with differents ways, with an intermediate buffer ?

Thanks for your answers !


#2

For the reading: make a separate thread that reads always like 64k of samples and puts them in a circular buffer. The audioIODeviceCallback() gets the samples directly from there.

For the recording: It would be way better to just put everything in circular buffers first (each channel = 1 circular buffer). This buffers would, in a separate thread, be read out and written to disk.

To do any non-audio I/O stuff in the audioDeviceIOCallback() is not a good idea.


#3

Thanks for your answer ! I’m going to try…