Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit ab052ce

Browse files
committed
fix: polyblepped sawtooth + fm = death
1 parent 5988e3d commit ab052ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/supradough/dough.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ const defaultDefaultValues = {
450450
z: 'triangle',
451451
pan: 0.5,
452452
fmh: 1,
453+
fmenv: 0, // differs from superdough
453454
};
454455

455456
let getDefaultValue = (key) => defaultDefaultValues[key];
@@ -540,6 +541,7 @@ export class DoughVoice {
540541
this.fft = this.fft ?? getDefaultValue('fft');
541542
this.pan = this.pan ?? getDefaultValue('pan');
542543
this.orbit = this.orbit ?? getDefaultValue('orbit');
544+
this.fmenv = this.fmenv ?? getDefaultValue('fmenv');
543545

544546
[this.attack, this.decay, this.sustain, this.release] = getADSRValues([
545547
this.attack,
@@ -551,6 +553,9 @@ export class DoughVoice {
551553
this._holdEnd = this._begin + this._duration; // needed for gate
552554
this._end = this._holdEnd + this.release + 0.01; // needed for despawn
553555

556+
if (this.s === 'saw' || this.s === 'sawtooth') {
557+
this.s = 'zaw'; // polyblepped saw when fm is applied
558+
}
554559
const SourceClass = oscillators[this.s] ?? TriOsc;
555560
this._sound = new SourceClass();
556561

@@ -638,7 +643,7 @@ export class DoughVoice {
638643
let fmi = this.fmi;
639644
if (this._fmenv) {
640645
const env = this._fmenv.update(t, gate, this.fmattack, this.fmdecay, this.fmsustain, this.fmrelease) ** 2;
641-
fmi = /* 2 ** */ this.fmenv * env * fmi; // todo: find good scaling
646+
fmi = this.fmenv * env * fmi;
642647
}
643648
const modfreq = freq * this.fmh;
644649
const modgain = modfreq * fmi;

0 commit comments

Comments
 (0)