Skip to content

Instantly share code, notes, and snippets.

@jcavena
Forked from jimnanney/game_loop.rb
Created August 27, 2016 21:01
Show Gist options
  • Save jcavena/18b051e21f65bf4f688adec626544e8f to your computer and use it in GitHub Desktop.
Save jcavena/18b051e21f65bf4f688adec626544e8f to your computer and use it in GitHub Desktop.
Sonic pi game loop
use_debug false
notes = (scale :b2, :minor_pentatonic, num_octaves: 3).shuffle
live_loop :drums do
sample :bd_haus, amp: 3
sleep 0.25
sample :drum_snare_hard
sleep 0.25
end
define :main_melody do
s = synth :mod_fm, sustain: 0.25, release: 0.7, attack: 0.2, amp: 0.5
control s, note: notes.tick
sleep 0.25
end
define :supersnare do
24.times do
sample :drum_snare_hard
sleep 0.125/2
end
end
live_loop :industry do
sample :loop_industrial, beat_stretch: 1
sleep 1
end
live_loop :main do
sleep 6
supersnare
tick_reset
122.times do
main_melody
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment