Remove webaudio from core dependencies
This commit is contained in:
parent
2a0635879c
commit
0f652e8b5b
5 changed files with 24 additions and 38 deletions
|
|
@ -42,9 +42,9 @@ const extensions = {
|
||||||
isMultiCursorEnabled: (on) =>
|
isMultiCursorEnabled: (on) =>
|
||||||
on
|
on
|
||||||
? [
|
? [
|
||||||
EditorState.allowMultipleSelections.of(true),
|
EditorState.allowMultipleSelections.of(true),
|
||||||
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
|
EditorView.clickAddsSelectionRange.of((ev) => ev.metaKey || ev.ctrlKey),
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
};
|
};
|
||||||
const compartments = Object.fromEntries(Object.keys(extensions).map((key) => [key, new Compartment()]));
|
const compartments = Object.fromEntries(Object.keys(extensions).map((key) => [key, new Compartment()]));
|
||||||
|
|
@ -268,11 +268,6 @@ export class StrudelMirror {
|
||||||
this.flash();
|
this.flash();
|
||||||
await this.repl.evaluate(this.code);
|
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() {
|
async stop() {
|
||||||
this.repl.scheduler.stop();
|
this.repl.scheduler.stop();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 createClock from './zyklus.mjs';
|
||||||
import { errorLogger, logger } from './logger.mjs';
|
import { errorLogger, logger } from './logger.mjs';
|
||||||
import { loadBuffer, renderPatternAudio, setAudioContext, superdough } from '@strudel/webaudio';
|
|
||||||
|
|
||||||
export class Cyclist {
|
export class Cyclist {
|
||||||
constructor({
|
constructor({
|
||||||
|
|
@ -111,15 +110,6 @@ export class Cyclist {
|
||||||
this.clock.start();
|
this.clock.start();
|
||||||
this.setStarted(true);
|
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() {
|
pause() {
|
||||||
logger('[cyclist] pause');
|
logger('[cyclist] pause');
|
||||||
this.clock.pause();
|
this.clock.pause();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://strudel.cc",
|
"homepage": "https://strudel.cc",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@strudel/webaudio": "workspace:*",
|
|
||||||
"fraction.js": "^5.2.1"
|
"fraction.js": "^5.2.1"
|
||||||
},
|
},
|
||||||
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",
|
"gitHead": "0e26d4e741500f5bae35b023608f062a794905c2",
|
||||||
|
|
@ -39,4 +38,4 @@
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vitest": "^3.0.4"
|
"vitest": "^3.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,8 +91,6 @@ export function repl({
|
||||||
|
|
||||||
const stop = () => scheduler.stop();
|
const stop = () => scheduler.stop();
|
||||||
const start = () => scheduler.start();
|
const start = () => scheduler.start();
|
||||||
const exportAudio = async (begin, end, sampleRate, downloadName = undefined) =>
|
|
||||||
await scheduler.exportAudio(begin, end, sampleRate, downloadName);
|
|
||||||
const pause = () => scheduler.pause();
|
const pause = () => scheduler.pause();
|
||||||
const toggle = () => scheduler.toggle();
|
const toggle = () => scheduler.toggle();
|
||||||
const setCps = (cps) => {
|
const setCps = (cps) => {
|
||||||
|
|
@ -259,23 +257,23 @@ export function repl({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const setCode = (code) => updateState({ code });
|
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 =
|
export const getTrigger =
|
||||||
({ getTime, defaultOutput }) =>
|
({ getTime, defaultOutput }) =>
|
||||||
async (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)
|
// ^ 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
|
// TODO: get rid of deadline after https://codeberg.org/uzu/strudel/pulls/1004
|
||||||
try {
|
try {
|
||||||
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
|
if (!hap.context.onTrigger || !hap.context.dominantTrigger) {
|
||||||
await defaultOutput(hap, deadline, duration, cps, t);
|
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');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { getDrawContext } from '@strudel/draw';
|
||||||
import { transpiler } from '@strudel/transpiler';
|
import { transpiler } from '@strudel/transpiler';
|
||||||
import {
|
import {
|
||||||
getAudioContextCurrentTime,
|
getAudioContextCurrentTime,
|
||||||
|
renderPatternAudio,
|
||||||
webaudioOutput,
|
webaudioOutput,
|
||||||
resetGlobalEffects,
|
resetGlobalEffects,
|
||||||
resetLoadedSounds,
|
resetLoadedSounds,
|
||||||
|
|
@ -203,8 +204,11 @@ export function useReplContext() {
|
||||||
const handleEvaluate = () => {
|
const handleEvaluate = () => {
|
||||||
editorRef.current.evaluate();
|
editorRef.current.evaluate();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExport = async (begin, end, sampleRate, downloadName = undefined) => {
|
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 handleShuffle = async () => {
|
||||||
const patternData = await getRandomTune();
|
const patternData = await getRandomTune();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue