How to loop over a sound recorded into a table?


#1

If I am recording a sample into a table, how would I determine the length of the sample?

Say I want to be able to loop over any sound (variable length) I record into the table - how would you go about doing that? In other words, a patch like the way a digital looper guitar pedal works.

Maybe there is a way of using the logic/counter object? Run counter while recording, then somehow map the counter value to the rate of a square wave LFO that is triggering table/play ...?


#2

Just some suggestions:
If you don't need to change playback speed, why not use table/play?
You can start and stop it anywhere in the table.
Make the table large enough to accommodate for the longest recording you think you will want to loop.
Then use timer/timeri to measure the time between two pedal stomps ("start-recording", "start-looping" commands) and set an lfo/square speed according to that to re-trigger table/play...
If I'm not mistaking, 1000/(0.333*n) where n = the output of timer/timeri will give frequency in Hertz.
But then you still have to map that to a value between -64 and 64 that corresponds to the dial position of lfo/square.
Also, dividing by an arbitrary number is not allowed (to protect us against divide by 0 I assume :smile: ).
A k-rate-ticks to Hz, or pitch (-64...64) object, anyone?
...
EDIT: I quickly tried out something, except for the "magic" that should happen inside the patch/patcher...

looper_stub.axp (4.7 KB)


#3

Right - this is what I need. Anyone know the correct way to map the k-rate counter (timer/timeri) to an LFO's pitch input?
This is the same thing you would do to make a tap-tempo LFO, right?


#4

ah, I just realized... I think you could count down from the timer's value and fire a trigger whenever it hits zero (also reset the timer) This avoids the need for mapping the timer value to a pitch input on the LFO. I'll patch it up ASAP and post my results. Seems like it should work.


#5

Done. Much simpler & more elegant solution. Works great. Check it out:
SimpleLooper.axp (7.4 KB)

Notes: this is recording from the audio inputs. It's stereo. Click the toggle to begin recording the loop; click again to stop recording & begin looping.