From 57d85ee7de5416d14c75d200e986ef4225ffabc4 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 18 Feb 2022 11:13:19 +0100 Subject: [PATCH] build --- docs/dist/App.js | 10 +++++-- docs/dist/shapeshifter.js | 4 +++ docs/dist/tunes.js | 61 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/docs/dist/App.js b/docs/dist/App.js index c19297a6..d47de94f 100644 --- a/docs/dist/App.js +++ b/docs/dist/App.js @@ -10,7 +10,12 @@ import hot from "../hot.js"; import {isNote} from "../_snowpack/pkg/tone.js"; import {useWebMidi} from "./midi.js"; const [_, codeParam] = window.location.href.split("#"); -const decoded = atob(decodeURIComponent(codeParam || "")); +let decoded; +try { + decoded = atob(decodeURIComponent(codeParam || "")); +} catch (err) { + console.warn("failed to decode", err); +} const getHotCode = async () => { return fetch("/hot.js").then((res) => res.text()).then((src) => { return src.split("export default").slice(-1)[0].trim(); @@ -39,6 +44,7 @@ function App() { const [activePattern, setActivePattern] = useState(); const dirty = code !== activeCode; const activateCode = (_code = code) => { + !cycle.started && cycle.start(); if (activeCode && !dirty) { setError(void 0); return; @@ -57,7 +63,6 @@ function App() { try { setActivePattern(() => _pattern); window.location.hash = "#" + encodeURIComponent(btoa(code)); - !cycle.started && cycle.start(); } catch (err) { setError(err); } @@ -106,6 +111,7 @@ function App() { switch (e.code) { case "Enter": activateCode(); + !cycle.started && cycle.start(); break; case "Period": cycle.stop(); diff --git a/docs/dist/shapeshifter.js b/docs/dist/shapeshifter.js index a37cd15d..5123d24f 100644 --- a/docs/dist/shapeshifter.js +++ b/docs/dist/shapeshifter.js @@ -24,3 +24,7 @@ export default (code) => { }); return codegen(shifted); }; + +// TODO: turn x.groove['[~ x]*2'] into x.groove('[~ x]*2'.m) +// and ['c1*2'].xx into 'c1*2'.m.xx ?? +// or just all templated strings?? x.groove(`[~ x]*2`) \ No newline at end of file diff --git a/docs/dist/tunes.js b/docs/dist/tunes.js index 2f58a6bc..6d0ea802 100644 --- a/docs/dist/tunes.js +++ b/docs/dist/tunes.js @@ -357,3 +357,64 @@ export const caverave = `() => { synths ).slow(2); }`; +export const caveravefuture = `() => { + const delay = new FeedbackDelay(1/8, .4).chain(vol(0.5), out); + const kick = new MembraneSynth().chain(vol(.8), out); + const snare = new NoiseSynth().chain(vol(.8), out); + const hihat = new MetalSynth().set(adsr(0, .08, 0, .1)).chain(vol(.3).connect(delay),out); + const bass = new Synth().set({ ...osc('sawtooth'), ...adsr(0, .1, .4) }).chain(lowpass(900), vol(.5), out); + const keys = new PolySynth().set({ ...osc('sawtooth'), ...adsr(0, .5, .2, .7) }).chain(lowpass(1200), vol(.5), out); + + const drums = stack( + \`c1*2\`.tone(kick).bypass(\`<0@7 1>/8\`), + \`~ \`.tone(snare).bypass(\`<0@7 1>/4\`), + \`[~ c4]*2\`.tone(hihat) + ); + + const thru = (x) => x.transpose(\`<0 1>/8\`).transpose(-1); + const synths = stack( + \`/2\`.scale(timeCat([3,'C minor'],[1,'C melodic minor']).slow(8)).groove(\`[~ x]*2\`) + .edit( + scaleTranspose(0).early(0), + scaleTranspose(2).early(1/8), + scaleTranspose(7).early(1/4), + scaleTranspose(8).early(3/8) + ).edit(thru).tone(keys).bypass(\`<1 0>/16\`), + \`/2\`.groove(\`x [~ x] <[~ [~ x]]!3 [x x]>@2\`).edit(thru).tone(bass), + \`/2\`.groove(\`~ [x@0.5 ~]\`.fast(2)).voicings().edit(thru).every(2, early(1/8)).tone(keys).bypass(\`<0@7 1>/8\`.early(1/4)), + ) + return stack( + drums.fast(2), + synths + ).slow(2); +}`; +export const caveravefuture2 = `const delay = new FeedbackDelay(1/8, .4).chain(vol(0.5), out); +const kick = new MembraneSynth().chain(vol(.8), out); +const snare = new NoiseSynth().chain(vol(.8), out); +const hihat = new MetalSynth().set(adsr(0, .08, 0, .1)).chain(vol(.3).connect(delay),out); +const bass = new Synth().set({ ...osc('sawtooth'), ...adsr(0, .1, .4) }).chain(lowpass(900), vol(.5), out); +const keys = new PolySynth().set({ ...osc('sawtooth'), ...adsr(0, .5, .2, .7) }).chain(lowpass(1200), vol(.5), out); + +const drums = stack( + "c1*2".tone(kick).bypass("<0@7 1>/8"), + "~ ".tone(snare).bypass("<0@7 1>/4"), + "[~ c4]*2".tone(hihat) +); + +const thru = (x) => x.transpose("<0 1>/8").transpose(-1); +const synths = stack( + "/2".scale(timeCat([3, 'C minor'], [1, 'C melodic minor']).slow(8)).groove("[~ x]*2") + .edit( + scaleTranspose(0).early(0), + scaleTranspose(2).early(1/8), + scaleTranspose(7).early(1/4), + scaleTranspose(8).early(3/8) + ).edit(thru).tone(keys).bypass("<1 0>/16"), + "/2".groove("x [~ x] <[~ [~ x]]!3 [x x]>@2").edit(thru).tone(bass), + "/2".groove("~ [x@0.5 ~]".fast(2)).voicings().edit(thru).every(2, early(1/8)).tone(keys).bypass("<0@7 1>/8".early(1/4)), +) +$: stack( + drums.fast(2), + synths +).slow(2); +`;