fix: move kabelsalat web to superdough

This commit is contained in:
Felix Roos 2026-01-18 22:04:49 +01:00
parent f5823ce981
commit 6981638f70
No known key found for this signature in database
5 changed files with 21 additions and 12 deletions

View file

@ -31,7 +31,6 @@
}, },
"homepage": "https://strudel.cc", "homepage": "https://strudel.cc",
"dependencies": { "dependencies": {
"@kabelsalat/web": "^0.4.1",
"fraction.js": "^5.2.1" "fraction.js": "^5.2.1"
}, },
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2", "gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",

View file

@ -12,7 +12,6 @@ import {
import { evalScope } from './evaluate.mjs'; import { evalScope } from './evaluate.mjs';
import { register, Pattern, isPattern, silence, stack } from './pattern.mjs'; import { register, Pattern, isPattern, silence, stack } from './pattern.mjs';
import { reset_state } from './impure.mjs'; import { reset_state } from './impure.mjs';
import { SalatRepl } from '@kabelsalat/web';
export function repl({ export function repl({
defaultOutput, defaultOutput,
@ -31,7 +30,6 @@ export function repl({
id, id,
mondo = false, mondo = false,
}) { }) {
const kabel = new SalatRepl({ localScope: true });
const state = { const state = {
schedulerError: undefined, schedulerError: undefined,
evalError: undefined, evalError: undefined,
@ -89,11 +87,6 @@ export function repl({
return silence; return silence;
}; };
const compileKabel = (code) => {
const node = kabel.evaluate(code);
return node.compile({ log: false });
};
// helper to get a patternified pure value out // helper to get a patternified pure value out
function unpure(pat) { function unpure(pat) {
if (pat._Pattern) { if (pat._Pattern) {
@ -221,7 +214,6 @@ export function repl({
setcps: setCps, setcps: setCps,
setCpm, setCpm,
setcpm: setCpm, setcpm: setCpm,
compileKabel,
}); });
}; };

View file

@ -37,6 +37,7 @@
}, },
"dependencies": { "dependencies": {
"@kabelsalat/lib": "^0.4.1", "@kabelsalat/lib": "^0.4.1",
"@kabelsalat/web": "^0.4.1",
"nanostores": "^0.11.3" "nanostores": "^0.11.3"
}, },
"engines": { "engines": {

View file

@ -260,6 +260,14 @@ export function loadWorklets() {
return workletsLoading; return workletsLoading;
} }
let kabel;
async function initKabelsalat() {
const { SalatRepl } = await import('@kabelsalat/web');
logger('[kabelsalat] ready');
kabel = new SalatRepl({ localScope: true });
return kabel;
}
// this function should be called on first user interaction (to avoid console warning) // this function should be called on first user interaction (to avoid console warning)
export async function initAudio(options = {}) { export async function initAudio(options = {}) {
const { const {
@ -306,6 +314,7 @@ export async function initAudio(options = {}) {
} catch (err) { } catch (err) {
console.warn('could not load AudioWorklet effects', err); console.warn('could not load AudioWorklet effects', err);
} }
await initKabelsalat();
logger('[superdough] ready'); logger('[superdough] ready');
} }
let audioReady; let audioReady;
@ -441,6 +450,14 @@ class Chain {
} }
} }
const compileKabel = (code) => {
if (!kabel) {
throw new Error('kabelsalat not loaded');
}
const node = kabel.evaluate(code);
return node.compile({ log: false });
};
export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => { export const superdough = async (value, t, hapDuration, cps = 0.5, cycle = 0.5) => {
// mapping from main FX and numbered FX chains to nodes // mapping from main FX and numbered FX chains to nodes
const nodes = { main: {} }; const nodes = { main: {} };

6
pnpm-lock.yaml generated
View file

@ -234,9 +234,6 @@ importers:
packages/core: packages/core:
dependencies: dependencies:
'@kabelsalat/web':
specifier: ^0.4.1
version: 0.4.1
fraction.js: fraction.js:
specifier: ^5.2.1 specifier: ^5.2.1
version: 5.2.1 version: 5.2.1
@ -524,6 +521,9 @@ importers:
'@kabelsalat/lib': '@kabelsalat/lib':
specifier: ^0.4.1 specifier: ^0.4.1
version: 0.4.1 version: 0.4.1
'@kabelsalat/web':
specifier: ^0.4.1
version: 0.4.1
nanostores: nanostores:
specifier: ^0.11.3 specifier: ^0.11.3
version: 0.11.3 version: 0.11.3