Looper Overdub trouble

Aaron Phillips's icon

Hi friends,
I'm working on creating my own looper and I've run into an issue.

Backstory
I've created a javascript file that will handle state changes and figured out how to get that to quantize in different ways based on which "state" it's going to enter. (For example, if going from "clear" to "record" the quantization is 1n, but if going from "record" to play, quantization is based on a counter that will count the bars and sync the "play" command to a power of 2. Overdubbing does not have a quantization to it as I'd like to be able to enable and disable overdubbing at any time. (similar to how Live's Looper device works)

All of this logic works and I can simulate looping in this way very accurately (including counting bars and calculating total loop length based on tempo and number of bars)

The Issue
The issue I'm having is that when it comes to actually overdubbing, I'm not able to figure out how to accurately do this.
My initial thought was to record~ to a buffer called ---temp and then crop that buffer and duplicate it to another buffer called ---loop, then play the ---loop buffer using groove~ and sending that feed back into ---temp along with a gated plugin~ that would open when overdub was active. The problem is I'm unsure how to configure this... The attempts I've made so far either don't work at all or slowly drift out of sync.

The whole point of this looper is that it stays in sync with the click track. I would happily use Ableton's stock looper if I could find a way to output the Status along with a float that showed loop progress. Unfortunately that's not available in the Live API at this time, though I have requested the feature.

I've attached the patch I have so far, if anyone has any ideas on how to get overdub working, I'd greatly appreciate it :)

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

1- I would never use any java stuff for real time looping.
2- overdubbing is very simple thing if you don't need undo.
feed both audio input and ouput of playing object into loop recording object through soft switch, like matrix and you have input and feedback control.

for real time looping you need 2 playback objects, 1 for feedback, the other one latency compensated for playback, otherwise you will get shifted overubbing.

Aaron Phillips's icon

Thanks for the reply! I’m not using JS for anything time sensitive, it’s just determining the which state the next button press will trigger based on the current state of two variables. This was just the cleanest way I could think to do that part.

I’m not terribly interested in undo, so it sounds like you’re confident this is possible :)

i’d love it if you could elaborate on your second point as I’m not familiar with matrix, soft switch, or how to do latency compensation to avoid overdub shift.

Source Audio's icon

here is very basic looper

Max Patch
Copy patch and select New From Clipboard in Max.

latency compensation is set to 441 samples or 10ms in sr 44.1 KHz
You need to measure it on your system and set accordingly.

loop size needs added signal vector size

Jean-Francois Charles's icon

Source Audio's example is nice. Here is a variation that can be used as a starting point, with more comments and no latency compensation.

Max Patch
Copy patch and select New From Clipboard in Max.