Created
November 9, 2022 18:51
-
-
Save amiika/85e3f0fadcae2b6917c7c9d8652c2835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bresenhams Euclidean algorithm in Ruby | |
def euclidean_bresenham(pulses, steps) | |
return Array.new(steps,1) if pulses>=steps | |
previous = nil | |
rhythm = [] | |
steps.times do |i| | |
div = ((pulses.to_f / steps) * i).to_i | |
rhythm.push(div == previous ? 0 : 1) | |
previous = div | |
end | |
rhythm | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment