Alsoknownasrox - Live Coding w/ Sonic Pi beat_stretch example 1

First example from this session by alsoknownasrox

# Roxanne Harris - Live Coding w/ Sonic Pi (beat_stretch)
# https://youtu.be/5dpM4ybRbgI
# https://in-thread.sonic-pi.net/t/alsoknownasrox-live-coding-w-sonic-pi-beatstretching-example-1/7204


live_loop :drum do
  t = 64
  slice = 0
  rpitch = 0
  (t).times do |i|
    if spread(1,64)[i]
      slice = [0,2,6].choose
      slice = 0
      rpitch = 0
    else
      slice = slice+1
      rpitch = rpitch -0.25*3
    end
    
    name = :loop_amen_full
    #   name = :loop_3d_printer
    #sample :loop_3d_printer
    
    num_slices = t
    beat_stretch = 4#16
    
    args = {beat_stretch: beat_stretch, lpf: nil, slice: slice, num_slices: num_slices, amp: 2, pitch: rpitch, window_size: 0.02, pitch_dis: 0.001}
    
    
    sample name, args, finish: 1 #
    
    look_duration = sample_duration name, args
    print look_duration
    sleep look_duration
  end
end
1 Like

# 221029 Building on the code above - version 1

use_bpm 100

live_loop :time, delay: 0.01 do
  sleep 1
end

live_loop :bass, sync: :time do
  tick
  use_synth :saw
  puts c = range(40,90,step: 0.1).look+rrand_i(0,39)
  p = range(-1,1,step: 0.1).mirror.look
  use_synth_defaults release: 0.25, cutoff: c, pan: p
  
  notes = :c2
  a=64/2
  notes = knit(:c2,a, :as1,a).look
  play notes
  play notes+12 if one_in(4)
  play notes+12+12 if one_in(8)
  play notes+12+12-[3,5,0].look if one_in(8)
  
  sleep 0.25
end


live_loop :kick, sync: :time do
  #  stop
  tick
  sample :bd_haus, cutoff: 85, amp: 2 #if spread(3,5).look and one_in(2)
  sleep 5 #0.25
  sample :bd_haus, cutoff: 115, amp: 2, start: 0.02, rate: 4 if  one_in(4)
  #sleep 0.25
end

with_fx :reverb do
  live_loop :drum, sync: :time do
    t = 64*2
    slice = 0
    rpitch = 0
    (t).times do |i|
      if spread(1,64)[i]
        slice = [0,2,6].choose
        #slice = 0
        rpitch = 12*2 #0
      else
        slice = slice+1
        rpitch = rpitch -0.25*3
      end
      
      name = :loop_amen_full
      #name = :loop_3d_printer
      #sample :loop_3d_printer
      
      num_slices = t
      beat_stretch = 8#16
      beat_stretch = 16#16
      beat_stretch = 16*2#16  nice
      #beat_stretch = 16*2*2#16
      
      args = {beat_stretch: beat_stretch, lpf: nil, slice: slice, num_slices: num_slices, amp: 2, pitch: rpitch, window_size: 0.02, pitch_dis: 0.001}
      
      
      sample name, args, finish: 0.25 #1
      
      look_duration = sample_duration name, args
      print look_duration
      sleep look_duration
    end
  end
end
1 Like