DJ Got Us Fallin' In Love - Usher ft. Pitbull using tb303

I started using Sonic Pi a long while back but couldn’t keep focus on learning and left it midway a few times now. However in my latest attempt at learning from the tutorials, I stumbled upon a tb303 loop and it instantly reminded me of this song. So here’s my rendition of it

use_bpm 120
define :my_sound do |n,l|
  use_synth :tb303
  play n , release: 0.4
  play n+16, release: 0.4, amp: 0.8
  sleep l
end

define :my_sound1 do |n,l|
  use_synth :tb303
  play n , release: 0.4
  play n+15, release: 0.4, amp: 0.8
  sleep l
end


define :my_sound2 do |n,l|
  use_synth :tb303
  play n , release: 0.4, amp: 0.55
  play n+15, release: 0.4, amp: 0.55
  sleep l
end


define :my_sound3 do |n,l|
  use_synth :tb303
  play n , release: 0.4, amp: 0.55
  play n+16, release: 0.4, amp: 0.55
  sleep l
end

1.times do
  my_sound1 43,1
  my_sound1 43,1
  my_sound1 43,0.75
  my_sound 46,0.75
  my_sound 46,0.5
  
  my_sound 41,1
  my_sound 41,1
  my_sound 41,0.75
  my_sound 46,0.75
  my_sound 46,0.5
  
  2.times do
    my_sound 39,1
    my_sound 39,1
    my_sound 39,0.75
    my_sound 46,0.75
    my_sound 46,0.5
  end
end


in_thread(name: :looper) do
  loop do
    my_sound2 43,1
    my_sound2 43,1
    my_sound2 43,0.75
    my_sound3 46,0.75
    my_sound3 46,0.5
    
    my_sound3 41,1
    my_sound3 41,1
    my_sound3 41,0.75
    my_sound3 46,0.75
    my_sound3 46,0.5
    
    2.times do
      my_sound3 39,1
      my_sound3 39,1
      my_sound3 39,0.75
      my_sound3 46,0.75
      my_sound3 46,0.5
    end
  end
end


loop do
  4.times do
    7.times do
      sample :drum_heavy_kick, amp: 3
      sleep 1
    end
    sample :drum_heavy_kick
    sleep 0.25
    sample :elec_flip, amp: 2
    sleep 0.25
    sample :elec_flip, amp: 2
    sleep 0.25
    sample :elec_flip, amp: 2
    sleep 0.25
  end
  
  loop do
    sample :drum_heavy_kick, amp: 3
    sleep 1
    sample :elec_hi_snare , amp: 2, release: 0.3
    sample :drum_heavy_kick, amp: 3
    sleep 1
    
  end
  sample :drum_heavy_kick
  sleep 0.25
  sample :elec_flip, amp: 2
  sleep 0.25
  sample :elec_flip, amp: 2
  sleep 0.25
  sample :elec_flip, amp: 2
  sleep 0.25
end
2 Likes

I would really appreciate it if someone could write a shorter version of this code or a more efficient version of it.