Merge pull request #963 from Tonejs/revert-942-buffer-player-timekeeping

Revert "fix for AudioBufferSourceNode stop time miscalculation"
This commit is contained in:
Yotam Mann 2021-10-15 15:40:14 -04:00 committed by GitHub
commit 5c15c9517d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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