This commit is contained in:
Felix Roos 2022-02-06 14:19:49 +01:00
parent 3919a21650
commit bc4893b4ba
3 changed files with 13 additions and 4 deletions

5
docs/dist/App.js vendored
View File

@ -4,8 +4,9 @@ import * as strudel from "../_snowpack/link/strudel.js";
import cx from "./cx.js";
import * as Tone from "../_snowpack/pkg/tone.js";
import useCycle from "./useCycle.js";
import {tetris} from "./tunes.js";
import * as tunes from "./tunes.js";
import _mini from "./mini.js";
const {tetris, tetrisMini} = tunes;
const {sequence, pure, reify, slowcat, fastcat, cat, stack, silence} = strudel;
const mini = _mini;
const parse = (code) => eval(code);
@ -17,7 +18,7 @@ synth.set({
}
});
function App() {
const [code, setCode] = useState(tetris);
const [code, setCode] = useState(tetrisMini);
const [log, setLog] = useState("");
const logBox = useRef();
const [error, setError] = useState();

11
docs/dist/mini.js vendored
View File

@ -1,9 +1,12 @@
import * as krill from "../_snowpack/link/repl/krill-parser.js";
import * as strudel from "../_snowpack/link/strudel.js";
const {sequence, silence} = strudel;
const {sequence, stack, silence} = strudel;
export function patternifyAST(ast) {
switch (ast.type_) {
case "pattern":
if (ast.arguments_.alignment === "v") {
return stack(...ast.source_.map(patternifyAST));
}
return sequence(...ast.source_.map(patternifyAST));
case "element":
if (ast.source_ === "~") {
@ -16,5 +19,9 @@ export function patternifyAST(ast) {
}
}
export default (...strings) => {
return sequence(...strings.map((str) => patternifyAST(krill.parse(`"${str}"`))));
const pattern = sequence(...strings.map((str) => {
const ast = krill.parse(`"${str}"`);
return patternifyAST(ast);
}));
return pattern;
};

1
docs/dist/tunes.js vendored
View File

@ -44,6 +44,7 @@ export const tetris = `stack(
)
)
)._slow(16);`;
export const tetrisMini = `mini('[[e5 [b4 c5] d5 [c5 b4]] [a4 [a4 c5] e5 [d5 c5]] [b4 [~ c5] d5 e5] [c5 a4 a4 ~] [[~ d5] [~ f5] a5 [g5 f5]] [e5 [~ c5] e5 [d5 c5]] [b4 [b4 c5] d5 e5] [c5 a4 a4 ~]],[[e2 e3 e2 e3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 a2 a3] [g#2 g#3 g#2 g#3 e2 e3 e2 e3] [a2 a3 a2 a3 a2 a3 b1 c2] [d2 d3 d2 d3 d2 d3 d2 d3] [c2 c3 c2 c3 c2 c3 c2 c3] [b1 b2 b1 b2 e2 e3 e2 e3] [a1 a2 a1 a2 a1 a2 a1 a2]]')._slow(16);`;
export const spanish = `slowcat(
stack('c4','eb4','g4'),
stack('bb3','d4','f4'),