https://github.com/zya/bjorklund
generates binary sequences based on Bjorklund algorithm
https://github.com/zya/bjorklund
Last synced: 6 months ago
JSON representation
generates binary sequences based on Bjorklund algorithm
- Host: GitHub
- URL: https://github.com/zya/bjorklund
- Owner: zya
- License: mit
- Created: 2015-04-28T20:24:26.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T06:50:26.000Z (about 3 years ago)
- Last Synced: 2025-08-09T02:33:57.939Z (7 months ago)
- Language: JavaScript
- Size: 379 KB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Bjorklund.js
Generates binary sequence patterns based on [Bjorklund](https://ics-web.sns.ornl.gov/timing/Rep-Rate%20Tech%20Note.pdf) algorithm.
> The algorithm solves the general problem of distributing `n`pulses over `m` “timing slots” in the most even way possible, even though `n`
may not necessarily be an even divisor of `m`.
These patterns can be used to achieve complex musical rhythms known as [Euclidean](http://cgm.cs.mcgill.ca/~godfried/publications/banff.pdf) Rhythms.
## Example Usage
`````
npm install bjorklund
`````
`````js
var bjork = require('bjorklund');
bjork(2,5); // returns '10100'
bjork(3,7); // returns '1010100'
bjork(5,16); // returns '1001001001001000'
bjork(4,16); // returns '1000100010001000'
`````
The method outputs the pattern as a string where `1`s represent pulses and `0`s represent empty slots.
### Dependencies
* Lodash