This commit is contained in:
Felix Roos 2022-03-17 22:19:37 +01:00
parent e694475556
commit 1182d0e45d
5 changed files with 27 additions and 15 deletions

8
docs/dist/euclid.js vendored
View file

@ -1,4 +1,4 @@
import {Pattern} from "../_snowpack/link/strudel.js";
import {Pattern, timeCat} from "../_snowpack/link/strudel.js";
import bjork from "../_snowpack/pkg/bjork.js";
import {rotate} from "../_snowpack/link/util.js";
const euclid = (pulses, steps, rotation = 0) => {
@ -11,4 +11,10 @@ const euclid = (pulses, steps, rotation = 0) => {
Pattern.prototype.euclid = function(pulses, steps, rotation = 0) {
return this.struct(euclid(pulses, steps, rotation));
};
Pattern.prototype.euclidLegato = function(pulses, steps, rotation = 0) {
const bin_pat = euclid(pulses, steps, rotation);
const firstOne = bin_pat.indexOf(1);
const gapless = rotate(bin_pat, firstOne).join("").split("1").slice(1).map((s) => [s.length + 1, true]);
return this.struct(timeCat(...gapless)).late(firstOne / steps);
};
export default euclid;

View file

@ -24,13 +24,11 @@ Pattern.prototype.voicings = function(range) {
}));
});
};
Pattern.prototype.rootNotes = function(octave = 2) {
Pattern.prototype._rootNotes = function(octave = 2) {
return this.fmap((value) => {
const [_, root] = value.match(/^([a-gA-G][b#]?).*$/);
return root + octave;
});
};
Pattern.prototype.define("voicings", (range, pat) => pat.voicings(range), {composable: true});
Pattern.prototype.define("rootNotes", (pat) => {
return pat.rootNotes();
}, {composable: true});
Pattern.prototype.define("rootNotes", (oct, pat) => pat.rootNotes(oct), {composable: true, patternified: true});