Remove webaudio from core dependencies

This commit is contained in:
Nikita
2025-10-20 21:24:27 +03:00
parent 2a0635879c
commit 0f652e8b5b
5 changed files with 24 additions and 38 deletions
+3 -8
View File
@@ -42,9 +42,9 @@ const extensions = {
isMultiCursorEnabled: (on) =>
on
? [
EditorState.allowMultipleSelections.of(true),
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
]
EditorState.allowMultipleSelections.of(true),
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
]
: [],
};
const compartments = Object.fromEntries(Object.keys(extensions).map((key) => [key, new Compartment()]));
@@ -268,11 +268,6 @@ export class StrudelMirror {
this.flash();
await this.repl.evaluate(this.code);
}
async exportAudio(begin, end, sampleRate, downloadName = undefined) {
await this.repl.evaluate(this.code, false);
await this.repl.exportAudio(begin, end, sampleRate, downloadName);
this.repl.scheduler.stop();
}
async stop() {
this.repl.scheduler.stop();
}
-10
View File
@@ -6,7 +6,6 @@ This program is free software: you can redistribute it and/or modify it under th
import createClock from './zyklus.mjs';
import { errorLogger, logger } from './logger.mjs';
import { loadBuffer, renderPatternAudio, setAudioContext, superdough } from '@strudel/webaudio';
export class Cyclist {
constructor({
@@ -111,15 +110,6 @@ export class Cyclist {
this.clock.start();
this.setStarted(true);
}
async exportAudio(begin, end, sampleRate, downloadName = undefined) {
if (!this.pattern) {
throw new Error('Scheduler: no pattern set! call .setPattern first.');
}
logger('[cyclist] exporting');
await renderPatternAudio(this.pattern, this.cps, begin, end, sampleRate, downloadName);
}
pause() {
logger('[cyclist] pause');
this.clock.pause();
+1 -2
View File
@@ -31,7 +31,6 @@
},
"homepage": "https://strudel.cc",
"dependencies": {
"@strudel/webaudio": "workspace:*",
"fraction.js": "^5.2.1"
},
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",
@@ -39,4 +38,4 @@
"vite": "^6.0.11",
"vitest": "^3.0.4"
}
}
}
+15 -17
View File
@@ -91,8 +91,6 @@ export function repl({
const stop = () => scheduler.stop();
const start = () => scheduler.start();
const exportAudio = async (begin, end, sampleRate, downloadName = undefined) =>
await scheduler.exportAudio(begin, end, sampleRate, downloadName);
const pause = () => scheduler.pause();
const toggle = () => scheduler.toggle();
const setCps = (cps) => {
@@ -259,23 +257,23 @@ export function repl({
}
};
const setCode = (code) => updateState({ code });
return { scheduler, evaluate, start, exportAudio, stop, pause, setCps, setPattern, setCode, toggle, state };
return { scheduler, evaluate, start, stop, pause, setCps, setPattern, setCode, toggle, state };
}
export const getTrigger =
({ getTime, defaultOutput }) =>
async (hap, deadline, duration, cps, t) => {
// ^ this signature is different from hap.context.onTrigger, as set by Pattern.onTrigger(onTrigger)
// TODO: get rid of deadline after https://codeberg.org/uzu/strudel/pulls/1004
try {
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
await defaultOutput(hap, deadline, duration, cps, t);
async (hap, deadline, duration, cps, t) => {
// ^ this signature is different from hap.context.onTrigger, as set by Pattern.onTrigger(onTrigger)
// TODO: get rid of deadline after https://codeberg.org/uzu/strudel/pulls/1004
try {
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
await defaultOutput(hap, deadline, duration, cps, t);
}
if (hap.context.onTrigger) {
// call signature of output / onTrigger is different...
await hap.context.onTrigger(hap, getTime(), cps, t);
}
} catch (err) {
errorLogger(err, 'getTrigger');
}
if (hap.context.onTrigger) {
// call signature of output / onTrigger is different...
await hap.context.onTrigger(hap, getTime(), cps, t);
}
} catch (err) {
errorLogger(err, 'getTrigger');
}
};
};
+5 -1
View File
@@ -9,6 +9,7 @@ import { getDrawContext } from '@strudel/draw';
import { transpiler } from '@strudel/transpiler';
import {
getAudioContextCurrentTime,
renderPatternAudio,
webaudioOutput,
resetGlobalEffects,
resetLoadedSounds,
@@ -203,8 +204,11 @@ export function useReplContext() {
const handleEvaluate = () => {
editorRef.current.evaluate();
};
const handleExport = async (begin, end, sampleRate, downloadName = undefined) => {
await editorRef.current.exportAudio(begin, end, sampleRate, downloadName);
await editorRef.current.evaluate();
await renderPatternAudio(editorRef.current.repl.state.pattern, editorRef.current.repl.scheduler.cps, begin, end, sampleRate, downloadName)
editorRef.current.repl.scheduler.stop();
};
const handleShuffle = async () => {
const patternData = await getRandomTune();