Skip to content

Instantly share code, notes, and snippets.

@sven-wachsmuth
Last active January 1, 2021 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sven-wachsmuth/dce6aa11e705ccda0e655a441567d13a to your computer and use it in GitHub Desktop.
Save sven-wachsmuth/dce6aa11e705ccda0e655a441567d13a to your computer and use it in GitHub Desktop.
Sonic Pi - Piano beat loop for use in 25 fps video
# piano-beat-loop.rb
# playing around with video and audio timing
# audio for video, timed to 25 fps / 16 fpb (frames per beat) --> 93.75 bpm
# Created by Sven Wachsmuth
# https://gist.github.com/sven-wachsmuth/dce6aa11e705ccda0e655a441567d13a
use_bpm 93.75;
# calc: 1 beat = 16 frames at 25 fps --> 1 beat = 16/25 = 0,64 s; 60 / 0.64 = 93.75 bpm
# reason: 1 frame is exactly 1/16 beat so every tap starts with a frame
# Piano-Part. It's a sample which will be pitched to different notes
live_loop :piano do
with_fx :hpf, cutoff: 60 do
sample :ambi_piano, pitch: [7,4,7,4,3,-1,3,-1].tick
sleep 4
end
if tick(:to_stop) > 14
stop
end
end
# main beat - 1, 2, 3, 4
live_loop :drum do
sample :drum_bass_hard, amp: [0.4,0.2,0.2,0.2].tick
sleep 1
if tick(:to_stop) > 62
stop
end
end
# second beat
live_loop :cymbal do
sample :drum_snare_soft, amp: 0.1, finish: 0.1+rrand(0,0.1), rate: 0.5
sleep [0.75,0.25, 1, 0.5,0.5, 0.25,0.25,0.5].tick
if tick(:to_stop) > 126
stop
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment