mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
only trigger the release if the value is above 0.
This commit is contained in:
parent
247c2ff5b3
commit
b6ab76de24
1 changed files with 19 additions and 7 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue