mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
allow using tidal function as template literal
+ add d1...d9
This commit is contained in:
parent
71f8c0745c
commit
2499c4057c
@ -1,4 +1,5 @@
|
||||
import { reify } from '@strudel/core';
|
||||
import { miniAllStrings } from '@strudel/mini';
|
||||
import { evaluate, loadParser } from 'hs2js';
|
||||
|
||||
function getInfixOperators() {
|
||||
@ -33,9 +34,23 @@ function getInfixOperators() {
|
||||
const ops = getInfixOperators();
|
||||
|
||||
export async function initTidal() {
|
||||
miniAllStrings(); // TODO: get rid of this and implement custom string parser in hs2js
|
||||
// TODO: implement this in regular land
|
||||
window.d1 = (pat) => pat.p('d1');
|
||||
window.d2 = (pat) => pat.p('d2');
|
||||
window.d3 = (pat) => pat.p('d3');
|
||||
window.d4 = (pat) => pat.p('d4');
|
||||
window.d5 = (pat) => pat.p('d5');
|
||||
window.d6 = (pat) => pat.p('d6');
|
||||
window.d7 = (pat) => pat.p('d7');
|
||||
window.d8 = (pat) => pat.p('d8');
|
||||
window.d9 = (pat) => pat.p('d9');
|
||||
return loadParser();
|
||||
}
|
||||
|
||||
export function tidal(code) {
|
||||
if (Array.isArray(code)) {
|
||||
code = code.join('');
|
||||
}
|
||||
return evaluate(code, window, ops);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user