the putback

This commit is contained in:
Marcel Blum 2021-10-18 22:08:40 -04:00 committed by GitHub
parent 5c15c9517d
commit 6decb02d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,7 +168,8 @@ export abstract class OneShotSource<
// schedule the stop callback
this._stopTime = this.toSeconds(time) + fadeOutTime;
this._stopTime = Math.max(this._stopTime, this.context.currentTime);
const nowTime = this.now();
this._stopTime = Math.max(this._stopTime, nowTime);
if (fadeOutTime > 0) {
// start the fade out curve at the given time
if (this._curve === "linear") {
@ -188,7 +189,7 @@ export abstract class OneShotSource<
this._curve === "exponential" ? fadeOutTime * 2 : 0;
this._stopSource(this.now() + additionalTail);
this._onended();
}, this._stopTime - this.context.currentTime);
}, this._stopTime - nowTime);
return this;
}