Code Share | 1979 Beat

Hi There everyone! Wanted to share something for anyone like me, I sometimes program drums so I can practice my guitar. Wanted to share with you a beat I made of one of my favorite songs of all time 1979 using the tutorial of Mister Bomb

use_bpm 127

beatscore = [1,0,2,0,1,1,2,1,0,1,2,0,1,1,2,0]

live_loop :kicks do
  with_fx :reverb, room: 0.3 do
    16.times do |i|
      puts i, beatscore[i]
      use_sample_defaults amp: rrand(0.95, 0.85)
      sample :drum_bass_soft if beatscore[i] == 1
      sample :drum_snare_soft if beatscore[i] == 2
      sleep 0.5
    end
  end
end

hhscore = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]

live_loop :hh do
  16.times do |i|
    puts i, hhscore[i]
    with_sample_defaults amp: rrand(0.65, 0.35) do
      sample :drum_cymbal_closed if hhscore[i] == 1
      sleep 0.5
    end
  end
end

Enjoy!

extra: the bass (the sound can be better)

bass = [1,1,1,1,1,1,1,2,0,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]

live_loop :bass do
  32.times do |i|
    puts i, bass[i]
    with_fx :distortion do
      use_synth :bass_foundation
      with_synth_defaults amp: 1, attack: 0.125 do
        play :eb2 if bass[i] == 1
        play :e2, slide: 3, sustain: 2 if bass[i] == 2
        play :b1 if bass[i] == 3
        play :a1 if bass[i] == 4
        sleep 0.5
      end
    end
  end
end
2 Likes

hi @lowtidefy

Well done. Let me introduce case

case a
when 1
  puts "It's 1"
when 3
  puts "It's 3"
when 4
  puts "It's 4"
else
  puts "It's something else"
end

# different type of case
case
when a > 100
  puts "It's greater than 100"
when a == 50
  puts "It's 50"
else
  puts "It's something else"
end

maybe you will find usefull to know you can use this solution.
Cheers and happy coding !

1 Like

Awesome! Checking it out and let me see if i can make some sense of it!

Hi there,

As far as I know there is no synth called :bass_foundation ,
good substitues might be :FM or :TRI.

You may have to shift notes up an octave if you use :FM,
otherwise they will be too deep…

Regards,

Eli…

live_loop :bass do
  32.times do |i|
    puts i, bass[i]
    with_fx :distortion do
      use_synth :tri
      with_synth_defaults amp: 1, attack: 0.125 do
        play :eb2 if bass[i] == 1
        play :e2, slide: 3, sustain: 2 if bass[i] == 2
        play :b1 if bass[i] == 3
        play :a1 if bass[i] == 4
        sleep 0.5
      end
    end
  end
end

Thank you for your suggestion,

I have attached a screenshot of the synth, I have the new Sonic Pi 4.0.0 Beta version (as a patreon) so I was not aware that it might be missing in the non beta

Happy Coding!

1 Like

Tried the code! Liked the :fm but had to tweek indeed to an octave higher…