This commit is contained in:
Felix Roos 2022-03-17 15:05:01 +01:00
parent 91c0a46ba9
commit 15e49952f9
12 changed files with 253 additions and 44 deletions

14
docs/dist/euclid.js vendored Normal file
View file

@ -0,0 +1,14 @@
import {Pattern} 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) => {
const b = bjork(steps, pulses);
if (rotation) {
return rotate(b, -rotation);
}
return b;
};
Pattern.prototype.euclid = function(pulses, steps, rotation = 0) {
return this.struct(euclid(pulses, steps, rotation));
};
export default euclid;

View file

@ -5,7 +5,8 @@ import "./voicings.js";
import "./tonal.js";
import "./xen.js";
import "./tune.js";
import "./tune.js";
import "./euclid.js";
import euclid from "./euclid.js";
import "./pianoroll.js";
import "./draw.js";
import * as uiHelpers from "./ui.js";
@ -28,7 +29,7 @@ function hackLiteral(literal, names, func) {
}
hackLiteral(String, ["mini", "m"], bootstrapped.mini);
hackLiteral(String, ["pure", "p"], bootstrapped.pure);
Object.assign(globalThis, bootstrapped, Tone, toneHelpers, voicingHelpers, drawHelpers, uiHelpers, {gist});
Object.assign(globalThis, bootstrapped, Tone, toneHelpers, voicingHelpers, drawHelpers, uiHelpers, {gist, euclid});
export const evaluate = async (code) => {
const shapeshifted = shapeshifter(code);
drawHelpers.cleanup();

2
docs/dist/parse.js vendored
View file

@ -12,6 +12,8 @@ const applyOptions = (parent) => (pat, i) => {
case "stretch":
const speed = new Fraction(operator.arguments_.amount).inverse().valueOf();
return reify(pat).fast(speed);
case "bjorklund":
return pat.euclid(operator.arguments_.pulse, operator.arguments_.step, operator.arguments_.rotation);
}
console.warn(`operator "${operator.type_}" not implemented`);
}

27
docs/dist/tunes.js vendored
View file

@ -515,3 +515,30 @@ stack(
.fast(2 / 3)
.tone(p.toDestination())
)`;
export const festivalOfFingers = `const chords = "<Cm7 Fm7 G7 F#7>";
piano().then(p=>stack(
chords.voicings().struct("x(3,8,-1)").velocity(.5).off(1/7,x=>x.transpose(12).velocity(.2)),
chords.rootNotes(2).struct("x(4,8,-2)"),
chords.rootNotes(4)
.scale(slowcat('C minor','F dorian','G dorian','F# mixolydian'))
.struct("x(3,8,-2)".fast(2))
.scaleTranspose("0 4 0 6".early(".125 .5")).layer(scaleTranspose("0,<2 [4,6] [5,7]>/4"))
).slow(2)
//.pianoroll()
.velocity(sine.struct("x*8").add(3/5).mul(2/5).fast(8))
.tone(p.chain(out())))`;
export const festivalOfFingers2 = `const chords = "<Cm7 Fm7 G7 F#7 >";
const scales = slowcat('C minor','F dorian','G dorian','F# mixolydian')
piano().then(p=>stack(
chords.voicings().struct("x(3,8,-1)").velocity(.5).off(1/7,x=>x.transpose(12).velocity(.2)),
chords.rootNotes(2).struct("x(4,8)"),
chords.rootNotes(4)
.scale(scales)
.struct("x(3,8,-2)".fast(2))
.scaleTranspose("0 4 0 6".early(".125 .5")).layer(scaleTranspose("0,<2 [4,6] [5,7]>/3"))
).slow(2).transpose(-1)
.legato(cosine.struct("x*8").add(4/5).mul(4/5).fast(8))
.velocity(sine.struct("x*8").add(3/5).mul(2/5).fast(8))
// .pianoroll()
.tone(p.chain(out())).fast(3/4)
)`;

View file

@ -26,7 +26,7 @@ Pattern.prototype.voicings = function(range) {
};
Pattern.prototype.rootNotes = function(octave = 2) {
return this.fmap((value) => {
const [_, root] = value.match(/^([a-gA-G])[b#]?.*$/);
const [_, root] = value.match(/^([a-gA-G][b#]?).*$/);
return root + octave;
});
};