Sonic Pi / Live Coding : Ritmos Euclidianos


• Referências:
The Euclidean Rhythms Online Demo
Euclidean Rhythms Wikipedia
The Euclidean Algorithm Generates Traditional Musical Rhythms
Music and Euclid's algorithm
Circles and Euclidean Rhythms: Off the Grid Music Makers
The Big Return Of Euclidean Rhythms?
Euclidean Rhythms
World Music Wikipedia


use_bpm 90
sample1 = :bd_klub
amp1 = 3
sample2 = :drum_cymbal_pedal
amp2 = 0.9
repeats = 4
interval = 2

sample 
notes = 2
total = 5
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 3
total = 4
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 3
total = 5
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 3
total = 7
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 3
total = 8
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 4; totalnotes = 7
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, totalnotes)
spark x
pos = 0
(totalnotes*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 4
totalnotes = 9
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, totalnotes)
spark x
pos = 0
(totalnotes*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep 1


notes = 4
totalnotes = 11
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, totalnotes)
spark x
pos = 0
(totalnotes*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep 1


notes = 5
totalnotes = 6
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, totalnotes)
spark x
pos = 0
(totalnotes*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep 1

notes = 5
total = 7
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 5
total = 8
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 5
total = 9
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 5
total = 12
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 5
total = 16
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 7
total = 8
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 7
total = 12
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 7
total = 16
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 9
total = 16
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 11
total = 24
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval


notes = 13
total = 24
puts "#{notes} notas, #{total} intervalos:"
x = (spread notes, total)
spark x
pos = 0
(total*repeats).times do
  sample sample1, amp: amp1 if x[pos] == true
  sample sample2, amp: amp2 if x[pos] == false
  sleep 0.5
  pos = pos + 1
end
sleep interval