pitch envelope

This commit is contained in:
Felix Roos
2025-06-08 00:43:58 +02:00
parent ab052ce1ac
commit ac7ee376e5
+15
View File
@@ -559,6 +559,16 @@ export class DoughVoice {
const SourceClass = oscillators[this.s] ?? TriOsc;
this._sound = new SourceClass();
if (this.penv) {
this._penv = new ADSR();
[this.pattack, this.pdecay, this.psustain, this.prelease] = getADSRValues([
this.pattack,
this.pdecay,
this.psustain,
this.prelease,
]);
}
if (this.fmi) {
this._fm = new SineOsc();
this.fmh = this.fmh ?? getDefaultValue('fmh');
@@ -650,6 +660,11 @@ export class DoughVoice {
freq = freq + this._fm.update(modfreq) * modgain;
}
if (this._penv) {
const env = this._penv.update(t, gate, this.pattack, this.pdecay, this.psustain, this.prelease) ** 2;
freq = freq + env * this.penv;
}
// sound source
if (this.s === 'pulse') {
s = this._sound.update(freq, this.pw ?? 0.5);