only trigger the release if the value is above 0.

This commit is contained in:
Yotam Mann 2016-01-28 19:10:05 -05:00
parent 247c2ff5b3
commit b6ab76de24

View file

@ -217,6 +217,7 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal",
Tone.Envelope.prototype.triggerRelease = function(time){
var now = this.now() + this.blockTime;
time = this.toSeconds(time, now);
if (this.getValueAtTime(time) > 0){
var release = this.toSeconds(this.release);
if (this._releaseCurve === Tone.Envelope.Type.Linear){
this._sig.linearRampToValueBetween(0, time, time + release);
@ -225,9 +226,20 @@ define(["Tone/core/Tone", "Tone/signal/TimelineSignal",
//silence the output entirely after the release
this._sig.setValueAtTime(0, release + time);
}
}
return this;
};
/**
* Get the scheduled value at the given time. This will
* return the unconverted (raw) value.
* @param {Number} time The time in seconds.
* @return {Number} The scheduled value at the given time.
*/
Tone.Envelope.prototype.getValueAtTime = function(time){
return this._sig.getValueAtTime(time);
};
/**
* triggerAttackRelease is shorthand for triggerAttack, then waiting
* some duration, then triggerRelease.