mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-24 22:55:38 -04:00
30 lines
665 B
JavaScript
30 lines
665 B
JavaScript
import { Pattern } from '@strudel/core';
|
|
import { connectToDestination, getAudioContext, getWorklet } from 'superdough';
|
|
|
|
let doughWorklet;
|
|
|
|
function initDoughWorklet() {
|
|
const ac = getAudioContext();
|
|
doughWorklet = getWorklet(
|
|
ac,
|
|
'dough-processor',
|
|
{},
|
|
{
|
|
outputChannelCount: [2],
|
|
},
|
|
);
|
|
connectToDestination(doughWorklet); // channels?
|
|
}
|
|
|
|
Pattern.prototype.supradough = function () {
|
|
return this.onTrigger((_, hap, __, cps, begin) => {
|
|
hap.value._begin = begin;
|
|
hap.value._duration = hap.duration / cps;
|
|
|
|
if (!doughWorklet) {
|
|
initDoughWorklet();
|
|
}
|
|
doughWorklet.port.postMessage(hap.value);
|
|
}, 1);
|
|
};
|