I only write this comment because in my application I also want such an “Feature”, I have done this in MaxMsp before, i am far away from a C-Guru, so keep the following as an Idea.
In my Setup it would be a footcontroller, because the hands of my Guitar-Synth-arist are on his instrument, so the whole thing would be more a 10 Button+ LED-Matrix-Thing
The Feature I will call “always recording mode”:
you play play play…and after a while you think - YESS that was so great - that was it! at this moment you Press the “REC” Button, from this point it starting Playback the Loop, and of course immideatly Record in a new track (always recording, you know)
The thing that you have to interact is now: to find out where the loop Starts, and where it ends
Find/Set the Loop Length:
When you working in a sequencer Setup, meens there is a drumcomputer out there or what ever trigger > you have to keep it ONBEAT, or OFFBEAT, for that you will have
3 Offset Buttons: +1, +2, +3 Steps
But with 1,2,3 Steps you cant offset 10000Steps, you Foot, or your Hand will fall up while your Hairs are gone gray… 
So you have to have
2 END-Crop Buttons : Decrease, Encrease Loop-End-Point, and that ±1-Step whise because the end is the point where you regocnized “man that was the loop of my live” so it cant be far away,
far away is maybe the
Loop-Start-Point , maybe 10000 Steps… but in most cases you did not now what you played 512 steps ago… (or did you?), so what do we need is to set the Ammount of Steps whe step back
So lets start with a predefinied STEP-BACK ammount - maybe 64 Steps, from there we start to go “more” back
In order of these we need a 3 more Buttons
1. range-Button" 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, (by pressing it you multiple times you can change the range) that change the Back-Step-Amount, it can be displayed as Numbers in 3x 7Segment LEDs or in a LED-Array
2. Loop-Start-Button-Decrease , step back the loop point with the amout from the “Range Button”
3. Loop-Start-Button-Encrease, step back the loop point with the ammount from the “Range Button”
next problem now is that you get bored by waiting again and again to hear THE Loop Point, maybe you have to wait 512 Steps----
…No you have no time to wait? ok, so when you press one of the Loop-Point Buttons > it, goes to a predefinied Loop Point at the End of the Sequence
(predefinied in a way to be in sync, with a predefinied, Beat Mode/Structure, 4/4, 3/8 or what ever - that is what you have to know before) maybe 8 Steps bevore Loop-End-Point.
withe the 3 Offset Buttons described above you now make some finetuning… when you have it, press CROP, to shrink it - for now it is stored in one of 4 loop Arrays, with maybe less functionality…
More techicly
you jam…after a while you think whow hoho that was it - this is the moment you hit “REC”
“REC” copy the REC-Variable(Array) into the Temporary-Playback-Variable(Array) and beginn to loop the recorded Sequence from same
“REC” then overwrite the REC-Variable-Array with “0” or “128”, and begin to write again in the Variable-Array from 0 to 10000.
In which Cell it writes defines the counter, which counts from “sequencer-start” message away, in 4/4 or whatever Predefinied structure, the counter is reset to 0 by pressing “REC” but not imideatly - only be the the first Trigger/Beat/1st 16th…
a bigger problem comes when you recording near the end of the array maybe 9900, because the counter restarts to 0 by coming to the 10000…headache :pinch:
The Offset things, and the Loop-Point things and the Loop-Range -Things - are simply modifieing the “counter-ranges” —offbeat-onbeat-offsets, by bewareing the counter from a defied ammount of ticks from the midiclock
here in a Matrix
[dwg.zip](< base_url >/applications/core/interface/file/attachment.php?id=11501)