func bresenhamEuclidean(onsets: Int, pulses: Int) -> [Int] {
let slope = Double(onsets) / Double(pulses)
var result = [Int]()
var previous: Int? = nil
for i in 0..<pulses {
let current = Int(floor(Double(i) * slope))
result.append(current != previous ? 1 : 0)
previous = current
}
return result
}
Created
March 5, 2018 01:24
-
-
Save crashingbooth/e9f0b7dbec8aecabf13db3663d28480f to your computer and use it in GitHub Desktop.
Bresenham Implementation of Euclidean Rhythm Generator
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment