fix: node export

This commit is contained in:
Felix Roos 2025-06-09 22:10:09 +02:00
parent e8254735bb
commit c9f494d865
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View file

@ -47,7 +47,8 @@ haps.forEach((hap) => {
console.log(`render ${seconds}s long buffer...`);
const buffer = new Float32Array(seconds * sampleRate);
while (dough.t <= buffer.length) {
buffer[dough.t] = dough.update();
dough.update();
buffer[dough.t] = dough.out[0];
}
console.log('done!');

View file

@ -150,7 +150,7 @@ class PulseOsc {
return 2 * phase - 1 - p;
}
update(freq, pw = 0.5) {
const dt = freq / sampleRate;
const dt = freq / SAMPLE_RATE;
let pulse = this.saw(0, dt) - this.saw(pw, dt);
this.phase = (this.phase + dt) % 1;
return pulse + pw * 2 - 1;