add prepare functionality to webaudio

This commit is contained in:
prezmop
2025-04-26 17:47:54 +09:00
parent af27364c45
commit 8674b61c2c
+5 -1
View File
@@ -5,7 +5,7 @@ This program is free software: you can redistribute it and/or modify it under th
*/
import * as strudel from '@strudel/core';
import { superdough, getAudioContext, setLogger, doughTrigger } from 'superdough';
import { superdough, prepare, getAudioContext, setLogger, doughTrigger } from 'superdough';
const { Pattern, logger, repl } = strudel;
setLogger(logger);
@@ -20,6 +20,9 @@ export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(h
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) =>
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
export const webaudioPrepare = (hap) =>
prepare(hap2value(hap));
Pattern.prototype.webaudio = function () {
return this.onTrigger(webaudioOutputTrigger);
};
@@ -28,6 +31,7 @@ export function webaudioRepl(options = {}) {
options = {
getTime: () => getAudioContext().currentTime,
defaultOutput: webaudioOutput,
defaultPrepare: webaudioPrepare,
...options,
};
return repl(options);