Synchronising audio tracks


Hi there,
I’m quite new to JUCE. Is there an easy way to synchronise two audio tracks? For example one audio track is already playing and I want to start the other on an exact sample of the other. My first idea was to count the samples in the audio callback and then sync the two tracks to this. Or is there another way like MIDI messages or something?

2 AudioFormatReaderSources out of sync 1-2 seconds

Depends what you mean by “track”, because there’s not really any such thing as a track in the juce codebase. If you mean two AudioTransportSources, then they should be syncronised as long as you start them both before the same audio callback.


Sorry, I mean two AudioTransportSources. Maybe I should give another example: Let’s say source A is playing. Now I want to start source B exactly when source A reaches sample number x. So my idea was to count samples in the audio io device callback and sync both sources someway to this number.


Well, as long as you start/stop them on the audio thread, then they’ll keep running in sync from that point.