]> 105106.c2e0p.group Git - sound.git/blobdiff - sound.js
When playing back in reverse, make sure the grain to be played takes that into account.
[sound.git] / sound.js
index a00d4223d34477b612d62aacd482fd209485bdac..6a481c58a98d1ed0c99b781022752a6512aa0be3 100644 (file)
--- a/sound.js
+++ b/sound.js
@@ -272,8 +272,10 @@ Sound.prototype = {
         this.node.buffer = this.buffer;
         this.node.playbackRate.value = this._playbackRate;
         this.node.onended = this.onended.bind(this);
         this.node.buffer = this.buffer;
         this.node.playbackRate.value = this._playbackRate;
         this.node.onended = this.onended.bind(this);
-               var remainingDuration = this._playbackRate < 0 ? this.nextStartTime : this.buffer.duration - this.nextStartTime;
-        this.node.start(0, this.nextStartTime, remainingDuration);
+        if (this._playbackRate < 0)
+            this.node.start(0, 0, this.nextStartTime);
+        else
+            this.node.start(0, this.nextStartTime, this.buffer.duration - this.nextStartTime);
 
         this.timeUpdateTimer = setInterval(this.sendTimeUpdate.bind(this), 250);
     },
 
         this.timeUpdateTimer = setInterval(this.sendTimeUpdate.bind(this), 250);
     },