Add swing to successive calls to do/end block

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

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

Options

shift:

How much time to delay/forward the block. Greater values produce more emphasised swing. Defaults to 0.1 beats.

pulse:

How often to apply the swing. Defaults to 4.

tick:

A key for the tick with which to count pulses. Override this if you have more than one with_swing block in your live_loop or thread to stop them interfering with each other.

offset:

Count offset - before modding the count with the pulse size - integer offset to add to the result of calling tick with the specified tick key (via the tick: opt)

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 on the 1st beat of every 4
 
 
 



# 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
# on the 1st beat of every 4
 
 



# 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
#  on the 1st beat of every 8
 
 



# 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
#  on the 1st beat of every 4
 
 
# plays the :elec_beep sample at double rate
#  slightly early except  on the 1st beat of every 4
 
 



# 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)
 



# Example 6

live_loop :foo do
  with_swing 0.1, offset: 2 do
    sample :elec_beep     
  end                     
  sleep 0.25
end


 
 
# plays the :elec_beep sample slightly late
# on the the 3rd beat of every 4
 
 



# Example 7

live_loop :foo do
  with_swing 0.1, pulse: 2, offset: 1 do
    sample :elec_beep     
  end                     
  sleep 0.25
end


 
 
# plays the :elec_beep sample slightly late
# on the 2nd beat of every 2