(max) synchronizing loops

example patcher

synchronizing playback of looped audio files without using the transport – two methods

The example patcher demonstrates how you can synchronize playback of two audio files of arbitrary lengths. One method is to use [wave~] objects, which playback according to a phase signal (typically supplied by a [phasor~]). The same [phasor~] can drive multiple [wave~] objects, keeping them synchronized. The other method is to use [groove~] for playback of one file, and then to use the sync output of [groove~] to drive other [wave~] objects.


This section discusses the top half of the patcher and the section outline in purple.

The [wave~] object plays back according to a phase signal. Using a [phasor~] with a positive frequency will cause the audio loaded into the buffer to play forward. [phasor~] outputs a continuous ramp signal from 0. to 1. If you want to express playback speed as a ratio you need to know the length of the audio file, which is expressed in ms. The [info~] object reports all sorts of useful information about an audio file loaded into a [buffer~], including its length. It needs a bang to report information, which can be supplied from the right outlet of [buffer~] upon completion of an audio file load. Divide 1000 by the length of the audio file to the get the frequency to playback the audio at unity speed.

The upper right portion of the patcher allows for speed to be expressed as a ratio by multiplying the playback ratio you want by the unity frequency. The new playback ratio becomes the argument of the multiply object, and then follows with a bang to the unity frequency (stored in the floating-point number object) to complete the execution of the multiplication operation. I’ve included a floating-point number box in the purple part of the patcher for controlling the playback ratio. It is sent to the upper right portion of the patcher to compute the [phasor~] playback frequency.

The second sound is synchronized to the playback of the first sound by connecting it to the same [phasor~] for playback. The addition of the [rate~] object allows for the possibility of expressing the speed of playback for the second sound as a multiplier (ratio) of the first. [rate~ 1. lock] translates to an initial frequency multiplier of the incoming phasor signal, and to lock the output phasor signal to the incoming phasor signal at the sample level. You can change the multiplier with a floating-point input to the right inlet of [rate~].

The two [snapshot~] and [slider] objects graphically show the phase of the two signals, from the [phasor~] and from the output of [rate~].

groove~ + wave~

The section enclosed in green shows another method for synchronizing two audio files. The [groove~] object sends a sync signal out its right-most outlet. The sync signal is the equivalent of a [phasor~] output, traversing from 0. to 1. over the course of the looping section. That sync signal can be sent to a [rate~] object feeding a [wave~] object for synchronized playback.

The main differences with this method as opposed to the first is that, a) you do not need to compute the unity playback ratio of the first audio file as [groove~] is driven by a playback ratio (not phase), and b) the output sync signal adjusts to changes in the start and end points of the loop specified to [groove~]. If you change the loop points, the sync signal will match its 0 – 1 output to the new loop points.

You can follow phase outputs with the [snapshot~]/[slider] combinations included in this portion of the patcher.


Leave a Reply