pitch envelope
This commit is contained in:
parent
ab052ce1ac
commit
ac7ee376e5
1 changed files with 15 additions and 0 deletions
|
|
@ -559,6 +559,16 @@ export class DoughVoice {
|
||||||
const SourceClass = oscillators[this.s] ?? TriOsc;
|
const SourceClass = oscillators[this.s] ?? TriOsc;
|
||||||
this._sound = new SourceClass();
|
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) {
|
if (this.fmi) {
|
||||||
this._fm = new SineOsc();
|
this._fm = new SineOsc();
|
||||||
this.fmh = this.fmh ?? getDefaultValue('fmh');
|
this.fmh = this.fmh ?? getDefaultValue('fmh');
|
||||||
|
|
@ -650,6 +660,11 @@ export class DoughVoice {
|
||||||
freq = freq + this._fm.update(modfreq) * modgain;
|
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
|
// sound source
|
||||||
if (this.s === 'pulse') {
|
if (this.s === 'pulse') {
|
||||||
s = this._sound.update(freq, this.pw ?? 0.5);
|
s = this._sound.update(freq, this.pw ?? 0.5);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue