mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
handle offset greater than the duration when set to loop
This commit is contained in:
parent
ecd5f9b5a3
commit
0285b4d83f
1 changed files with 11 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue