half working samples

This commit is contained in:
Felix Roos 2025-06-08 02:04:49 +02:00
parent ac7ee376e5
commit 0f2aa9569b
No known key found for this signature in database
4 changed files with 182 additions and 12 deletions

View file

@ -6,7 +6,19 @@ class DoughProcessor extends AudioWorkletProcessor {
constructor() {
super();
this.dough = new Dough(sampleRate, currentTime);
this.port.onmessage = (event) => this.dough.scheduleSpawn(event.data);
this.port.onmessage = (event) => {
if (event.data.spawn) {
this.dough.scheduleSpawn(event.data.spawn);
} else if (event.data.sample) {
this.dough.loadSample(event.data.sample, event.data.channels);
} else if (event.data.samples) {
event.data.samples.forEach(([name, channels]) => {
this.dough.loadSample(name, channels);
});
} else {
console.log('unrecognized event type', event.data);
}
};
}
process(inputs, outputs, params) {
if (this.disconnected) {