Skip to content

Instantly share code, notes, and snippets.

@lcoullet
Last active March 31, 2017 15:03
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 lcoullet/354a99320d51b71b3b56 to your computer and use it in GitHub Desktop.
Save lcoullet/354a99320d51b71b3b56 to your computer and use it in GitHub Desktop.
[Euclide's knocking at my door] A little test made with Sonic Pi #tags: music, sonicpi
def distribute(pulses, steps, sound)
pauses = steps - pulses
per_pulse = (pauses / pulses).to_i
remainder = pauses % pulses
rythm = []
pulses.times do |pulse|
rythm << 1
per_pulse.times { rythm << 0 }
rythm << 0 if pulse < remainder
end
return euclidean(rythm, sound)
end
def euclidean(rythm, sound)
rythm.each do |d|
if d == 1
sample sound
sleep 1
elsif
sleep 1
end
end
end
use_bpm 160
with_fx :compressor do
in_thread do
24.times do
distribute(1,3, :drum_tom_hi_soft)
end
end
in_thread do
sleep 3
16.times do
distribute(2,5, :drum_tom_lo_soft)
end
end
in_thread do
sleep 8
12.times do
distribute(3,7, :drum_tom_mid_soft)
end
end
in_thread do
sleep 14
8.times do
distribute(4,9, :drum_cymbal_pedal)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment