Record from 2 audio devices simultaneously

Hello community. I’m working on a project based on binaural recordings to measure both noise and binaural parameters (IACC). In order to do that I’m creating a program to record audio from two devices at the same time (two USB microphones) and basically monitor environmental noise 24/7 (it needs to be 24/7).

I’ve been following the AudioRecording demo project. Basically I created a RecordingComponent, which inherits from AudioSource so that I can select each device independently on each instance of it, since I don’t have stereo input channels but two mono input channels to record. There’s a button on the MainComponent calling the record() function on each instance of my RecorderComponent. This functions creates a WAV file (just like the AudioRecordingDemo) named after the date and time of the recording and starts filling it with the input from the device. Right now I can get it to record two devices (each one creating a different WAV file, one for L and one for R). After two minutes I stop that recording and start a new one all over again for each device using a HighResolutionTimer. However, these recordings are not synchronized to start exactly at the same time.

I’ve been trying with AsyncUpdater, the RecordingComponent inherits from this class and on the MainComponent I call the triggerAsyncUpdate() function. This seems to be better, but eventually after many hours of recording there’s a delay between the left and right channels .

  1. What would you recommend to perfectly sync recordings of two different audio devices being used in the same application?

  2. Should I save the recorded samples first andcreate the WAV file when the recording stops instead of creating it first and then filling it continuously?

PD: I’m testign mainly on Windows 10. However I have tested on Raspberry Pi4, getting exactly the same results. The idea is to use multiple Raspberry Pi4 devices to create a noise
monitoring network.

I appreciate your help!

I would definitely recommend you to not use two individual audio devices if you want to record two precisely synced audio streams, which is what I guess what you definetively need for your use-case. The software-part left aside for a moment, you might know that each audio device generates its own clock signal to clock its A/D converters from some sort of internal PLL and this clock is what determines the sample rate used to sample your microphone signals – the sample clock is not created by your computer. Especially with (probably cheap) USB microphones, but even for high end devices they will start drifting against each other over time, leading to an increasing misalignment over time and your computer handling both devices can not really do anything about that.

Then in software, the computer will serve your two devices one after another, so achieving perfect synchronisation on that level is also far from trivial, even if you don’t care about sample exact alignment.

My recommendation: Better go and get yourself a simple cheap two channel USB audio interface and attach two microphones to it. This will prevent a lot of headache implementation wise and perfect synchronised audio streams.


Thanks for the help PluginPenguin. I actually didn’t consider the internal clock each device has, which would make it almost impossible to sync both input streams. I guess I’m glad to know that you can actually record more than one device simultaneously with JUCE. However, for this specific application I’m gonna need perfectly synced channels, because when recording binaural audio every milisecond counts if you want to preserve spaciality. I’ll try some other stuff and see if I can get some stereo interface and a couple of analog mics.

N.B. Fabian Renn-Giles gave a great talk at the last ADC 2021 (sadly no published videos yet), where he talked about strategies to synchronise the individual clocks of independent devices.
It is far from trivial. They can and will even drift apart over time.

1 Like