sndloop — A sound looper with pitch control.
This opcode records input audio and plays it back in a loop with user-defined duration and crossfade time. It also allows the pitch of the loop to be controlled, including reversed playback.
asig -- output sig
krec -- 'rec on' signal, 1 when recording, 0 otherwise
kpitch -- pitch control (transposition ratio); negative values play the loop back in reverse
ktrig -- trigger signal: when 0, processing is bypassed. When switched on (ktrig >= 1), the opcode starts recording until the loop memory is full. It then plays the looped sound until it is switched off again (ktrig = 0). Another recording can start again with ktrig >= 1.
Example 431. Example
asig in ; get the signal in ktrig line 0, 1, 1 ; trigger signal aout,krec sndloop asig, 1, ktrig, 4, 0.05 ; rec starts at 1 sec, for 4 secs 0.05 crossfade printk 1, krec ; prints the recording signal out aout
The example above shows the basic operation of sndloop. Pitch can be controlled at the k-rate, recording is started as soon as the trigger value is >= 1. Recording can be restarted by making the trigger 0 and then 1 again.