A loop for live coding

live_loop  name (symbol)

Run the block in a new thread with the given name, and loop it forever. Also sends a cue with the same name each time the block runs. If the block is given a parameter, this is given the result of the last run of the loop (with initial value either being 0 or an init arg).

It is possible to delay the initial trigger of the live_loop on creation with both the delay: and sync: opts. See their respective docstrings. If both delay: and sync: are specified, on initial live_loop creation first the delay will be honoured and then the sync.

Introduced in v2.1

Options

init:

initial value for optional block arg

auto_cue:

enable or disable automatic cue (default is true)

delay:

Initial delay in beats before the live_loop starts. Default is 0.

sync:

Initial sync symbol. Will sync with this symbol before the live_loop starts.

sync_bpm:

Initial sync symbol. Will sync with this symbol before the live_loop starts. Live loop will also inherit the BPM of the thread which cued the symbol.

seed:

override initial random generator seed before starting loop.

Examples

# Example 1

live_loop :ping do
  sample :elec_ping
  sleep 1
end


 
 
 
 



# Example 2

live_loop :foo do |a| 
  puts a              
  sleep 1
  a += 1              
end


# pass a param (a) to the block (inits to 0)
# prints out all the integers
 
# increment a by 1 (last value is passed back into the loop)