optimization to turn off oscillator after play

This commit is contained in:
tambien 2018-06-13 19:04:02 -04:00
parent 55eed8c295
commit 031dc98898

View file

@ -92,6 +92,9 @@ define(["Tone/core/Tone", "Tone/source/OmniOscillator", "Tone/instrument/Instrum
this.oscillator.frequency.exponentialRampToValueAtTime(note, time + this.toSeconds(this.pitchDecay));
this.envelope.triggerAttack(time, velocity);
this.oscillator.start(time);
if (this.envelope.sustain === 0){
this.oscillator.stop(time + this.envelope.attack + this.envelope.decay);
}
return this;
};