comparison 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
comparison
equal deleted inserted replaced
2589:373b8ecf9476 2592:89f787e2e90c
1676 console.error('FATAL - Passed id was undefined - AudioEngineContext.play(id)'); 1676 console.error('FATAL - Passed id was undefined - AudioEngineContext.play(id)');
1677 return; 1677 return;
1678 } else { 1678 } else {
1679 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]); 1679 interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]);
1680 } 1680 }
1681 var setTime = audioContext.currentTime;
1681 if (this.synchPlayback && this.loopPlayback) { 1682 if (this.synchPlayback && this.loopPlayback) {
1682 // Traditional looped playback 1683 // Traditional looped playback
1683 var setTime = audioContext.currentTime + specification.crossFade;
1684 for (var i = 0; i < this.audioObjects.length; i++) { 1684 for (var i = 0; i < this.audioObjects.length; i++) {
1685 this.audioObjects[i].play(audioContext.currentTime); 1685 this.audioObjects[i].play(audioContext.currentTime);
1686 if (id == i) { 1686 if (id == i) {
1687 this.audioObjects[i].loopStart(setTime); 1687 this.audioObjects[i].loopStart(setTime);
1688 } else { 1688 } else {
1689 this.audioObjects[i].loopStop(setTime); 1689 this.audioObjects[i].loopStop(setTime + specification.crossFade);
1690 } 1690 }
1691 } 1691 }
1692 } else { 1692 } else {
1693 var setTime = audioContext.currentTime + specification.crossFade;
1694 for (var i = 0; i < this.audioObjects.length; i++) { 1693 for (var i = 0; i < this.audioObjects.length; i++) {
1695 if (i != id) { 1694 if (i != id) {
1696 this.audioObjects[i].stop(setTime); 1695 this.audioObjects[i].stop(setTime + specification.crossFade);
1697 } else if (i == id) { 1696 } else if (i == id) {
1698 this.audioObjects[id].play(setTime); 1697 this.audioObjects[id].play(setTime);
1699 } 1698 }
1700 } 1699 }
1701 } 1700 }
1936 } 1935 }
1937 }; 1936 };
1938 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); 1937 this.outputGain.gain.cancelScheduledValues(audioContext.currentTime);
1939 if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) { 1938 if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) {
1940 this.metric.startListening(audioEngineContext.timer.getTestTime()); 1939 this.metric.startListening(audioEngineContext.timer.getTestTime());
1941 this.outputGain.gain.setValueAtTime(this.onplayGain, startTime); 1940 this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, startTime + specification.crossFade);
1942 this.interfaceDOM.startPlayback(); 1941 this.interfaceDOM.startPlayback();
1943 } else { 1942 } else {
1944 this.outputGain.gain.setValueAtTime(0.0, startTime); 1943 this.outputGain.gain.linearRampToValueAtTime(0.0, startTime);
1945 } 1944 }
1946 if (audioEngineContext.loopPlayback) { 1945 if (audioEngineContext.loopPlayback) {
1947 this.bufferNode.loopStart = this.specification.startTime || 0; 1946 this.bufferNode.loopStart = this.specification.startTime || 0;
1948 this.bufferNode.loopEnd = this.specification.stopTime - this.specification.startTime || this.buffer.buffer.duration; 1947 this.bufferNode.loopEnd = this.specification.stopTime - this.specification.startTime || this.buffer.buffer.duration;
1949 this.bufferNode.start(startTime); 1948 this.bufferNode.start(startTime);
1959 if (this.bufferNode != undefined) { 1958 if (this.bufferNode != undefined) {
1960 this.metric.stopListening(audioEngineContext.timer.getTestTime(), this.getCurrentPosition()); 1959 this.metric.stopListening(audioEngineContext.timer.getTestTime(), this.getCurrentPosition());
1961 this.bufferNode.stop(stopTime); 1960 this.bufferNode.stop(stopTime);
1962 this.bufferNode = undefined; 1961 this.bufferNode = undefined;
1963 } 1962 }
1964 this.outputGain.gain.setValueAtTime(0.0, stopTime); 1963 this.outputGain.gain.linearRampToValueAtTime(0.0, stopTime);
1965 this.interfaceDOM.stopPlayback(); 1964 this.interfaceDOM.stopPlayback();
1966 }; 1965 };
1967 1966
1968 this.getCurrentPosition = function () { 1967 this.getCurrentPosition = function () {
1969 var time = audioEngineContext.timer.getTestTime(); 1968 var time = audioEngineContext.timer.getTestTime();