Skip to content

Commit 0b8219d

Browse files
committed
Addresses issue #9. Adding and removing effects is done seamlessly in looped sounds.
1 parent 4cfc90b commit 0b8219d

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

distr/Pizzicato.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,15 @@
434434

435435
this.stopWithSustain();
436436

437-
this.offsetTime = Pz.context.currentTime - this.lastTimePlayed;
437+
var elapsedTime = Pz.context.currentTime - this.lastTimePlayed;
438+
439+
// If we are using a buffer node - potentially in loop mode - we need to
440+
// know where to re-start the sound independently of the loop it is in.
441+
if (this.sourceNode.buffer)
442+
this.offsetTime = elapsedTime % (this.sourceNode.buffer.length / Pz.context.sampleRate);
443+
else
444+
this.offsetTime = elapsedTime;
445+
438446
this.trigger('pause');
439447
}
440448
},

0 commit comments

Comments
 (0)