Add swing to successive calls to do/end block

with_swing  shift (beats), pulse (number), tick (symbol)

Runs block within a time_warp except for once every pulse consecutive runs (defaulting to 4). When used for rhythmical purposes this results in one in every pulse calls of the block being ‘on beat’ and the rest shifted forward or backwards in time by shift beats.

Introduced in v3.0

Examples

# Example 1

live_loop :foo do
  with_swing 0.1 do
    sample :elec_beep     
  end
  sleep 0.25
end



 
 
# plays the :elec_beep sample late except for every 4th time
 
 
 



# Example 2

live_loop :foo do
  with_swing -0.1 do
    sample :elec_beep     
  end                     
  sleep 0.25
end



 
 
# plays the :elec_beep sample slightly early
# except for every 4th time
 
 



# Example 3

live_loop :foo do
  with_swing -0.1, pulse: 8 do
    sample :elec_beep     
  end                     
  sleep 0.25
end



 
 
# plays the :elec_beep sample slightly early
# except for every 8th time
 
 



# Example 4



live_loop :foo do
  with_swing 0.14, tick: :a do
    sample :elec_beep     
  end                     
  with_swing -0.1, tick: :b do
    sample :elec_beep, rate: 2 
  end                          
  sleep 0.25
end



# Use unique tick names if you plan on using with_swing
# more than once in any given live_loop or thread.
 
 
# plays the :elec_beep sample slightly late
# except for every 4th time
 
# plays the :elec_beep sample at double rate
#  slightly early except for every 4th time
 
 



# Example 5

live_loop :foo do
  with_swing 0.1 do
    cue :tick             
  end
  sleep 0.25
end
live_loop :bar do
  sync :tick
  sample :elec_beep      
                         
                         
end



 
 
# send out cue messages with swing timing
 
 
 
 
 
# sync on the swing cue messages to bring the swing into
# another live loop (sync will match the timing and clock of
# the sending live loop)