Midi Looper Attempt

I’ve made a custom synth for use with my Linnstrument and it works pretty well. Huzzah to Juce!
Now I’m interested including a Midi Looper: You punch in while playing to start recording notes, then punch out to stop recording and start playing them back and solo over that. I actually have a crude prototype of it working now but I’m running into issues and am guessing my entire approach is half-baked.
Basically, during recording I’m using a MultiTimer for each MidiMessage being received from my midi controller. I fire those off with the loop interval (once it’s determined at punch-out time) and I get note playback and looping. However the rhythm is off; notes play back but with “slightly” wrong timing (like 1/8 second) that doesn’t match my recorded timing. I’m guessing this is either a limitation of using a MultiTimer for this, or needing to incorporate the message TimeStamp into the looping.
If anyone has any guesses or leads for me to follow based on that much info I’d appreciate it.
I’ve looked over all the posts I can find on Midi playback and Midi Time Stamps and can’t find a similar “live looper” example to learn from. Is there a better part of Juce I should be exploiting than a custom-rolled MultiTimer solution? Thx.

You need to be recording the sample position of each note that comes in, probably translating it into a timestamp. That way you can then generate the message when looping, converting the stored timestamp into the appropriate sample position within the buffer.

See this JUCE tutorial for more details.

1 Like