SonicPiで曲作り 3

use_bpm 45
use_random_seed 1

tr = 0
t = 0
c = [
  :Gb3,:Gb3,:Gb3,:Gb3,:Cb3,:Db3,:Cb3,:Db3,
  :Ab3,:Ab3,:Ab3,:Ab3,:Bb3,:Bb3,:Bb3,:Bb3,
  :Eb4,:Eb4,:Db4,:Db4,:Gb4,:Gb4
]
a = c[0]


in_thread do
  cue :start
  with_fx :reverb, room: 0.99, mix: 0.7 do
    synth :saw , note: scale(:Gb3, :minor_pentatonic).shuffle.take(3), attack: 1.5, release: 16, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:Gb4, :minor_pentatonic).shuffle.take(3), attack: 1.0, release: 12, amp: 0.1
    sleep 2;
    synth :saw , note: scale(:Gb5, :minor_pentatonic).shuffle.take(3), attack: 0.5, release: 8, amp: 0.1
    sleep 4;
  end
end

with_fx :reverb, room: 0.99, mix: 0.7 do
  4.times do
    synth :sine , note: scale(:Gb3, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1;
    synth :sine , note: scale(:Gb4, :minor_pentatonic).shuffle.take(2), attack: 0, release: 0.1, amp: 0.2
    sleep 1
  end
end

cue :bd1
cue :bd

live_loop :zoo do
  cue :bd1
  tr = c[t]
  if(tr != nil)
    a = tr
  else
    t=0
    tr = c[t]
    a = tr
  end
  
  t=t+1
  print t,a
  sleep 2
end

live_loop :bd1 do
  sync "/cue/bd"
  sample :bd_ada, amp: 0.8
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.4
  sleep 0.25
end

live_loop :bd2 do
  sync "/cue/bd"
  sleep 3
  sample :bd_ada, amp: 0.4
  sleep 0.5
  sleep 0.25
  sample :bd_ada, amp: 0.2
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :loop2 do
    ##| sync "/cue/bd1"
    cue :bd
    synth :piano ,
      note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
      attack: 0, release: 0.15, amp: [1, 0.5, 0.25].choose
    sleep 4;
  end
end


with_fx :reverb, room: 0.99, mix: 0.7 do
  live_loop :melo do
    
    4.times do
      synth :piano ,
        note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
        attack: 0, release: 2, amp: 0.5
      sleep 1
      
      use_synth :piano;
      32.times do
        play choose(scale(a, :minor_pentatonic, num_octaves: 2)), attack: 0, release: 0.5, amp: [0.2, 0.1, 0.4].choose
        sleep 0.125
      end
    end
    
  end
end


with_fx :reverb, room: 0.5, mix: 0.7 do
  live_loop :melo2 do
    
    if(!one_in(8))
      32.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125
      end
    else
      
      28.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125
      end
      
      8.times do
        synth :pretty_bell ,
          note: scale(a, :minor_pentatonic, num_octaves: 2).shuffle.take(3),
          attack: 0, release: 0.15, amp: [0.2, 0.1, 0.25].choose
        sleep 0.125/2
      end
    end
    
  end
end