Mercurial > hg > webaudioevaluationtool
changeset 2509:04498bccfccf
Merge branch 'master' of https://github.com/BrechtDeMan/WebAudioEvaluationTool
author | www-data <www-data@sucuk.dcs.qmul.ac.uk> |
---|---|
date | Tue, 18 Oct 2016 16:22:54 +0100 |
parents | 52c819e710ca (current diff) 9b536838a962 (diff) |
children | cbec4dd5a1e9 |
files | |
diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/js/core.js Thu Oct 13 11:23:13 2016 +0100 +++ b/js/core.js Tue Oct 18 16:22:54 2016 +0100 @@ -1361,7 +1361,7 @@ // because web audio will optimise and any route which does not go to the destination gets ignored. this.outputGain = audioContext.createGain(); this.fooGain = audioContext.createGain(); - this.fooGain.gain = 0; + this.fooGain.gain.value = 0; // Use this to detect playback state: 0 - stopped, 1 - playing this.status = 0; @@ -1381,6 +1381,14 @@ this.pageStore = null; + // Chrome 53+ Error solution + // Empty buffer for keep-alive + var nullBuffer = audioContext.createBuffer(1, audioContext.sampleRate, audioContext.sampleRate); + this.nullBufferSource = audioContext.createBufferSource(); + this.nullBufferSource.buffer = nullBuffer; + this.nullBufferSource.loop = true; + this.nullBufferSource.start(0); + // Create store for new audioObjects this.audioObjects = []; @@ -1745,6 +1753,7 @@ // Connect buffer to the audio graph this.outputGain.connect(audioEngineContext.outputGain); + audioEngineContext.nullBufferSource.connect(this.outputGain); // the audiobuffer is not designed for multi-start playback // When stopeed, the buffer node is deleted and recreated with the stored buffer. @@ -1833,9 +1842,10 @@ event.currentTarget.owner.stop(audioContext.currentTime + 1); } }; + this.outputGain.gain.cancelScheduledValues(audioContext.currentTime); if (!audioEngineContext.loopPlayback || !audioEngineContext.synchPlayback) { this.metric.startListening(audioEngineContext.timer.getTestTime()); - this.outputGain.gain.setValueAtTime(this.onplayGain, 0.0); + this.outputGain.gain.setValueAtTime(this.onplayGain, startTime); this.interfaceDOM.startPlayback(); } else { this.outputGain.gain.setValueAtTime(0.0, startTime); @@ -1858,7 +1868,7 @@ this.bufferNode.stop(stopTime); this.bufferNode = undefined; } - this.outputGain.gain.value = 0.0; + this.outputGain.gain.setValueAtTime(0.0, stopTime); this.interfaceDOM.stopPlayback(); };