changeset 2530:6461c2012340

Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author www-data <www-data@sucuk.dcs.qmul.ac.uk>
date Wed, 09 Nov 2016 14:20:57 +0000
parents 78a6c78ba4fd (current diff) 21110fddb0af (diff)
children 829a67368dc4
files
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Wed Nov 09 13:20:49 2016 +0000
+++ b/js/core.js	Wed Nov 09 14:20:57 2016 +0000
@@ -1584,22 +1584,21 @@
             } else {
                 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]);
             }
+            var setTime = audioContext.currentTime;
             if (this.synchPlayback && this.loopPlayback) {
                 // Traditional looped playback
-                var setTime = audioContext.currentTime + specification.crossFade;
                 for (var i = 0; i < this.audioObjects.length; i++) {
                     this.audioObjects[i].play(audioContext.currentTime);
                     if (id == i) {
                         this.audioObjects[i].loopStart(setTime);
                     } else {
-                        this.audioObjects[i].loopStop(setTime);
+                        this.audioObjects[i].loopStop(setTime + specification.crossFade);
                     }
                 }
             } else {
-                var setTime = audioContext.currentTime + specification.crossFade;
                 for (var i = 0; i < this.audioObjects.length; i++) {
                     if (i != id) {
-                        this.audioObjects[i].stop(setTime);
+                        this.audioObjects[i].stop(setTime + specification.crossFade);
                     } else if (i == id) {
                         this.audioObjects[id].play(setTime);
                     }
@@ -1845,10 +1844,10 @@
             this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
             if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) {
                 this.metric.startListening(audioEngineContext.timer.getTestTime());
-                this.outputGain.gain.setValueAtTime(this.onplayGain, startTime);
+                this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, startTime + specification.crossFade);
                 this.interfaceDOM.startPlayback();
             } else {
-                this.outputGain.gain.setValueAtTime(0.0, startTime);
+                this.outputGain.gain.linearRampToValueAtTime(0.0, startTime);
             }
             if (audioEngineContext.loopPlayback) {
                 this.bufferNode.loopStart = this.specification.startTime || 0;
@@ -1868,7 +1867,7 @@
             this.bufferNode.stop(stopTime);
             this.bufferNode = undefined;
         }
-        this.outputGain.gain.setValueAtTime(0.0, stopTime);
+        this.outputGain.gain.linearRampToValueAtTime(0.0, stopTime);
         this.interfaceDOM.stopPlayback();
     };