Meandering notes

Following a question on in_thread which I answered earlier today, I played around with the chord definition I proposed and ended up with the piece below. I love the way that Sonic Pi is so flexible and easily and quickly lets you develop an idea with pleasing (to me at least) results.

#meanderingNotes by Robin Newman
#resulting from a question asked on in_thread
use_random_seed 2020
use_debug false
define :linkbpm do #adjusts link speed up and down 
  
  in_thread do #in thread raise the link bpm from 40 to 100
    set_link_bpm! 40
    sp=40
    60.times do
      sleep 0.5
      sp+=1
      set_link_bpm! sp
      
    end
    sleep rt(30) #real time 30 seond wait
    60.times do #decrease the link speed back to 40
      sleep 0.5
      sp -= 1
      set_link_bpm! sp
    end
  end
end

linkbpm #start link bpm variation
with_fx :reverb, room: 0.5,mix: 0.6 do #add some reverb
  n= chord_names
  define :chordPlusOctave do |base,type| #defines 4 note chord
    (chord(base,type).to_a + [note(base)+12])#.sort
  end
  use_synth :tb303
  
  live_loop :test do
    base=[:c4,:f4,:g4,:g3].choose #select root of chord
    type = n.choose #chose chord type
    tick_reset #this tick used to traverse through the chord
    detail= "chord is #{base} #{type} including octave note" #description
    rev = dice(2)==1 #random flag to reverse the chord
    l= chordPlusOctave(base,type) #choose the chord notes
    if dice(2)==1 #sort the chord sometimes
      l=l.sort
      detail=detail+", sorted" #indicate sorted
    end
    if rev
      detail=detail+" and reversed" #indicate reversed
    end
    puts detail #print description
    cut=rrand_i(80,110) #choose cutoff
    density [1,3,1,1,2].choose do #vary density
      chordPlusOctave(base,type).length.times do #arppegiate chord notes
        play l.tick,cutoff: cut,amp: 0.5,pan: (-1)**dice(2) if rev #vary pan and direction
        play l.reverse.tick,cutoff: cut,amp: 0.5 ,pan: (-1)**dice(2) if !rev
        sleep 0.25
      end
    end
    stop if vt>90
  end
  
end#reverb
3 Likes