Tempo-Synced Loop Machine

Official support for: sonicbirth.sourceforge.net
Post Reply New Topic
RELATED
PRODUCTS

Post

So, I'm trying to come up with a loop machine plugin that takes MIDI CC input that tells it when to begin recording and when to stop recording (and begin looping playback), with the resulting loop quantized in real-time to length of some multiple of one measure-length. I only need the plugin to handle layer of audio at a time; I can use more than one instance of it in the host for more layers.

I've already the easy part of it working.
The plugin currently:
Receives MIDI CC input to control a slider with possible values 0, 1, and 2,
Passes those values to a Bufferizer as the "mode" input,
And lets the input of the plugin pass through when the bufferizer is in mode 0 or 2 (mode 1 is playback, so in that case, playback is passed to the output)

Now, I know that beat information comes only at the beginning of each bar, and I'm okay with that, because when I'm doing live loops, I'll usually want to sync them to barlines anyway.

I can envision the logic of the syncing portion to work roughly like this:
Keep at all times a beat timer that resets on each beat event received from host.
When a "begin record" event is received, capture the time (t) on the beat timer
When a "stop record / begin playback" event is received,
Determine if the event is "early" or "late"
(that is, if it is closer to the next beat event or the previous one)
(the projected next beat event can be computed with tempo info from host)
If early, just delay the "stop rec / begin play" event until next beat event
(or by the difference computed from the projected next beat)
If late, immediately begin playback from <beginning+"lateness">
AND set Bufferizer to end playback at <end-"lateness">
AND all subsequent playbacks should begin from beginning, not <b+lateness>

Now, I'm new to SonicBirthing, and I'm having the most trouble figuring out how to capture values like (t). I always end up routing a changing value instead of the static one at a certain point. I'm used to working with PureData, so I expected this sort of logic to be feasible, but if its not, could someone maybe suggest some alternate logic path (or perhaps a way to wrap PureData or even C logic into a SonicBirth plugin?)

Post Reply

Return to “SonicBirth”