Skip to contents

The algorithm evenly distributes a specified number of beats in a total specified number of steps, returning a binary vector where 1s indicate the occurrence of a beat.

Usage

bresenham_euclidean(beats, steps, start = 1)

Arguments

beats

Integer, number of beats to distribute.

steps

Integer, total number of steps across which the beats are to be distributed.

start

Integer, the starting value in sequence. Default is 1.

Value

A numerical vector of size steps containing 1s where beats are present and 0s elsewhere.

Details

Converted to R from discussions of Euclidean Algorithms in this post https://medium.com/code-music-noise/euclidean-rhythms-391d879494df. See also Toussaint, Godfried. 2005. “The Euclidean Algorithm Generates Traditional Musical Rhythms.” In, 4756. https://archive.bridgesmathart.org/2005/bridges2005-47.html

Examples

if (FALSE) {
bresenham_euclidean(5, 16)
bresenham_euclidean(7, 20, 2)
}