School is over - let's play sonic pi

Hi,

Just some code for young people on this day in France where the school is over !
Just to learn the basics.

##| nlb - 03-07-2020
##| school-is-over
## chords progression with bass and melody based on notes coming from the current chord
##

use_bpm 96

progression = ( ring
                (chord :a, 'minor'),
                (chord :f, 'major'),
                (chord :c, 'major'),
                (chord :d, 'minor'),
                )

current_chord = progression[0]

with_fx :echo, mix: 0.25 do
  live_loop :chords_player, delay: 0.5  do
    use_synth :piano
    4.times do
      play current_chord
      sleep 1
    end
  end
end


with_fx :reverb, mix: 0.7 do
  live_loop :melody do
    use_synth :pretty_bell
    use_synth_defaults attack: 0, release: 0.2
    play current_chord[0] # to get the first note of the chord
    sleep 1
    play current_chord[4] # to get the 5th note of the chord
    sleep 0.5
    play current_chord[3] # to get the 4th note of the chord
    sleep 0.5
  end
end

live_loop :bass_root do
  use_synth :fm
  use_octave -1 # to play one octave lower.
  play current_chord[0] # to get the first note of the chord
  sleep 1
end


live_loop :nextChord do
  current_chord = progression.tick
  sleep 4 - 0.01 # love love love 4-0.01 to get the live_loop works.
end


live_loop :bd do
  sample :drum_bass_hard
  sleep 1.5
  sample :drum_bass_hard
  sleep 0.5
  sample :drum_bass_hard
  sleep 2
end

live_loop :sn do
  sleep 1
  sample :drum_snare_hard, compress: 1
  sleep 1
end

live_loop :hh do
  8.times do
    sample :drum_cymbal_closed, amp: [0.5, 2, 0.5, 2].tick
    sleep 0.5
  end
end

1 Like