move supradough to separate package

This commit is contained in:
Felix Roos 2025-06-06 16:17:05 +02:00
parent ccc90d547c
commit 43c05cb504
No known key found for this signature in database
15 changed files with 102 additions and 33 deletions

View file

@ -4,7 +4,6 @@
import OLAProcessor from './ola-processor';
import FFT from './fft.js';
import { Dough } from './dough.mjs';
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
const _mod = (n, m) => ((n % m) + m) % m;
@ -896,27 +895,3 @@ class ByteBeatProcessor extends AudioWorkletProcessor {
}
registerProcessor('byte-beat-processor', ByteBeatProcessor);
class DoughProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.dough = new Dough(sampleRate, currentTime);
this.port.onmessage = (event) => this.dough.scheduleSpawn(event.data);
}
process(inputs, outputs, params) {
if (this.disconnected) {
return false;
}
const output = outputs[0];
for (let i = 0; i < output[0].length; i++) {
this.dough.update();
for (let c = 0; c < output.length; c++) {
//prevent speaker blowout via clipping if threshold exceeds
output[c][i] = clamp(this.dough.channels[c], -1, 1);
}
}
return true; // keep the audio processing going
}
}
registerProcessor('dough-processor', DoughProcessor);