diff js/core.js @ 2592:89f787e2e90c

Merge branch 'vnext' into Dev_main # Conflicts: # tests/examples/mushra_example.xml
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Wed, 09 Nov 2016 13:49:45 +0000
parents 5f7c11fa5f83 c0854362d09d
children 9bb878bf41d8
line wrap: on
line diff
--- a/js/core.js	Sat Nov 05 11:21:54 2016 +0000
+++ b/js/core.js	Wed Nov 09 13:49:45 2016 +0000
@@ -1678,22 +1678,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);
                     }
@@ -1938,10 +1937,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;
@@ -1961,7 +1960,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();
     };