From 0285b4d83fd84a45cfb711eb29434cc0407eb66b Mon Sep 17 00:00:00 2001 From: Yotam Mann Date: Thu, 29 Sep 2016 09:57:31 -0400 Subject: [PATCH] handle offset greater than the duration when set to loop --- Tone/source/Player.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Tone/source/Player.js b/Tone/source/Player.js index 8f7c6674..cf5225cc 100644 --- a/Tone/source/Player.js +++ b/Tone/source/Player.js @@ -200,6 +200,17 @@ define(["Tone/core/Tone", "Tone/core/Buffer", "Tone/source/Source"], function(To this._source.connect(this.output); //start it if (this._loop){ + //modify the offset if it's greater than the loop time + var loopEnd = this._source.loopEnd || this._buffer.duration; + var loopStart = this._source.loopStart; + var loopDuration = loopEnd - loopStart; + if (offset > loopDuration){ + offset = loopStart + (offset % loopDuration); + if (offset > loopEnd){ + offset -= loopDuration; + } + } + this._source.start(startTime, offset); } else { this._source.start(startTime, offset, duration);