build
This commit is contained in:
parent
91c0a46ba9
commit
15e49952f9
12 changed files with 253 additions and 44 deletions
41
docs/_snowpack/pkg/bjork.js
Normal file
41
docs/_snowpack/pkg/bjork.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
function bjorklund(slots, pulses){
|
||||
var pattern = [],
|
||||
count = [],
|
||||
remainder = [pulses],
|
||||
divisor = slots - pulses,
|
||||
level = 0,
|
||||
build_pattern = function(lv){
|
||||
if( lv == -1 ){ pattern.push(0); }
|
||||
else if( lv == -2 ){ pattern.push(1); }
|
||||
else {
|
||||
for(var x=0; x<count[lv]; x++){
|
||||
build_pattern(lv-1);
|
||||
}
|
||||
|
||||
if(remainder[lv]){
|
||||
build_pattern(lv-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
while(remainder[level] > 1){
|
||||
count.push(Math.floor(divisor/remainder[level]));
|
||||
remainder.push(divisor%remainder[level]);
|
||||
divisor = remainder[level];
|
||||
level++;
|
||||
}
|
||||
count.push(divisor);
|
||||
|
||||
build_pattern(level);
|
||||
|
||||
return pattern.reverse();
|
||||
}
|
||||
|
||||
|
||||
var bjork = function(m, k){
|
||||
if(m > k) return bjorklund(m, k);
|
||||
else return bjorklund(k, m);
|
||||
};
|
||||
|
||||
export default bjork;
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
"imports": {
|
||||
"@tonaljs/tonal": "./@tonaljs/tonal.js",
|
||||
"@tonejs/piano": "./@tonejs/piano.js",
|
||||
"bjork": "./bjork.js",
|
||||
"chord-voicings": "./chord-voicings.js",
|
||||
"codemirror/lib/codemirror.css": "./codemirror/lib/codemirror.css",
|
||||
"codemirror/mode/javascript/javascript.js": "./codemirror/mode/javascript/javascript.js",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue