fix: node export
This commit is contained in:
parent
e8254735bb
commit
c9f494d865
2 changed files with 3 additions and 2 deletions
|
|
@ -47,7 +47,8 @@ haps.forEach((hap) => {
|
||||||
console.log(`render ${seconds}s long buffer...`);
|
console.log(`render ${seconds}s long buffer...`);
|
||||||
const buffer = new Float32Array(seconds * sampleRate);
|
const buffer = new Float32Array(seconds * sampleRate);
|
||||||
while (dough.t <= buffer.length) {
|
while (dough.t <= buffer.length) {
|
||||||
buffer[dough.t] = dough.update();
|
dough.update();
|
||||||
|
buffer[dough.t] = dough.out[0];
|
||||||
}
|
}
|
||||||
console.log('done!');
|
console.log('done!');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ class PulseOsc {
|
||||||
return 2 * phase - 1 - p;
|
return 2 * phase - 1 - p;
|
||||||
}
|
}
|
||||||
update(freq, pw = 0.5) {
|
update(freq, pw = 0.5) {
|
||||||
const dt = freq / sampleRate;
|
const dt = freq / SAMPLE_RATE;
|
||||||
let pulse = this.saw(0, dt) - this.saw(pw, dt);
|
let pulse = this.saw(0, dt) - this.saw(pw, dt);
|
||||||
this.phase = (this.phase + dt) % 1;
|
this.phase = (this.phase + dt) % 1;
|
||||||
return pulse + pw * 2 - 1;
|
return pulse + pw * 2 - 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue