Blues band with swinging drums, bass and piano - my first creation

Here’s the code. I had fun building this up and figuring out some of the functionality.

# by Adrian Cockcroft
use_bpm 140
swing=0.15 # set to 0 for straight beats, 0.15 for a shuffle
key= :Eb3  # E flat is a common blues key

with_fx :reverb do
  
  live_loop :drums do
    sample :hat_tap, amp: 0.9
    sample :drum_bass_hard, amp: 0.9
    sleep 0.5+swing
    sample :hat_tap, amp: 0.7
    sample :drum_bass_hard, amp: 0.8
    sleep 0.5-swing
    sample :drum_snare_hard, amp: 0.8
    sample :hat_tap, amp: 0.8
    sleep 0.5+swing
    sample :hat_tap, amp: 0.7
    sleep 0.5-swing
  end
  
  blues_scale = (ring key, key, key+12, key+12, key+10, key+10, key+5, key+3)
  durs=(ring 0.5,0.5, 0.5,0.5, 0.5,0.5, 0.5,0.5)
  twelvebar = (ring 0, 0, 0, 0, 5, 5, 0, 0, 7, 5, 0, 7)
  
  live_loop :bass do
    use_synth :fm
    use_transpose twelvebar.tick(:bar)
    4.times do
      use_synth_defaults release: 0.5+swing, amp: 1.0, pan: 0.3
      play blues_scale.tick(:note) #tick advances to next note each pass of the loop
      sleep durs.look(:note)+swing #look gives same as tick value without advancing it
      use_synth_defaults release: 0.5-swing, amp: 0.8, pan: 0.3
      play blues_scale.tick(:note) #tick advances to next note each pass of the loop
      sleep durs.look(:note)-swing #look gives same as tick value without advancing it
    end
  end
  
  live_loop :chords do
    use_synth :piano
    use_synth_defaults pan: -0.30, amp: 1.0, stereo_width: 0.3
    play_chord chord(key+24+twelvebar.tick(:chords), :minor), decay: 2, release: 2
    sleep 4 #change every bar
  end
  
  live_loop :solo do
    use_synth :piano
    use_synth_defaults pan: -0.30, amp: 1.0, stereo_width: 0.3
    sleep 2
    pattern1 = shuffle(scale(key+12*dice(2)+twelvebar.look(:chords), :minor_pentatonic))
    pattern2 = shuffle(scale(key+24+twelvebar.look(:chords), :minor_pentatonic))
    play_pattern_timed pattern1, 0.25
    play_pattern_timed pattern2, 0.5
    play_pattern_timed pattern2, 0.25
  end
end
3 Likes