Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2949:311596aedb7b
Fix for #249
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Mon, 30 Oct 2017 15:24:22 +0000 |
parents | 49b0b1e245af |
children | 3dc059f3b57c 451e104f8667 |
comparison
equal
deleted
inserted
replaced
2948:bfd19c39f2f3 | 2949:311596aedb7b |
---|---|
1081 p = new DOMParser(); | 1081 p = new DOMParser(); |
1082 lastNodeStart = new Date(); | 1082 lastNodeStart = new Date(); |
1083 this.popupResponse.innerHTML = ""; | 1083 this.popupResponse.innerHTML = ""; |
1084 this.popupTitle.innerHTML = ""; | 1084 this.popupTitle.innerHTML = ""; |
1085 var strings = node.specification.statement.split("\n"); | 1085 var strings = node.specification.statement.split("\n"); |
1086 strings.forEach(function(e,i,a){ | 1086 strings.forEach(function (e, i, a) { |
1087 a[i] = e.trim(); | 1087 a[i] = e.trim(); |
1088 }); | 1088 }); |
1089 node.specification.statement = strings.join("\n"); | 1089 node.specification.statement = strings.join("\n"); |
1090 var statementElements = p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").querySelector("body").children; | 1090 var statementElements = p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").querySelector("body").children; |
1091 while(statementElements.length > 0) { | 1091 while (statementElements.length > 0) { |
1092 this.popupTitle.appendChild(statementElements[0]); | 1092 this.popupTitle.appendChild(statementElements[0]); |
1093 } | 1093 } |
1094 if (node.specification.type == 'question') { | 1094 if (node.specification.type == 'question') { |
1095 postQuestion.call(this, node); | 1095 postQuestion.call(this, node); |
1096 } else if (node.specification.type == 'checkbox') { | 1096 } else if (node.specification.type == 'checkbox') { |
1910 this.id = id; | 1910 this.id = id; |
1911 this.state = 0; // 0 - no data, 1 - ready | 1911 this.state = 0; // 0 - no data, 1 - ready |
1912 this.url = null; // Hold the URL given for the output back to the results. | 1912 this.url = null; // Hold the URL given for the output back to the results. |
1913 this.metric = new metricTracker(this); | 1913 this.metric = new metricTracker(this); |
1914 this.storeDOM = null; | 1914 this.storeDOM = null; |
1915 this.playing = false; | |
1915 | 1916 |
1916 // Bindings for GUI | 1917 // Bindings for GUI |
1917 this.interfaceDOM = null; | 1918 this.interfaceDOM = null; |
1918 this.commentDOM = null; | 1919 this.commentDOM = null; |
1919 | 1920 |
1986 } | 1987 } |
1987 this.storeDOM.setAttribute('presentedId', interfaceObject.getPresentedId()); | 1988 this.storeDOM.setAttribute('presentedId', interfaceObject.getPresentedId()); |
1988 }; | 1989 }; |
1989 | 1990 |
1990 this.listenStart = function (setTime) { | 1991 this.listenStart = function (setTime) { |
1991 if (this.outputGain.gain.value !== this.onplayGain) { | 1992 if (this.playing === false) { |
1992 playCounter++; | 1993 playCounter++; |
1993 this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, setTime); | 1994 this.outputGain.gain.linearRampToValueAtTime(this.onplayGain, setTime); |
1994 this.metric.startListening(audioEngineContext.timer.getTestTime()); | 1995 this.metric.startListening(audioEngineContext.timer.getTestTime()); |
1995 this.bufferNode.playbackStartTime = audioEngineContext.timer.getTestTime(); | 1996 this.bufferNode.playbackStartTime = audioEngineContext.timer.getTestTime(); |
1996 this.interfaceDOM.startPlayback(); | 1997 this.interfaceDOM.startPlayback(); |
1998 this.playing = true; | |
1997 } | 1999 } |
1998 }; | 2000 }; |
1999 | 2001 |
2000 this.listenStop = function (setTime) { | 2002 this.listenStop = function (setTime) { |
2001 if (this.outputGain.gain.value !== 0.0) { | 2003 if (this.playing === true) { |
2002 this.outputGain.gain.linearRampToValueAtTime(0.0, setTime); | 2004 this.outputGain.gain.linearRampToValueAtTime(0.0, setTime); |
2003 this.metric.stopListening(audioEngineContext.timer.getTestTime(), this.getCurrentPosition()); | 2005 this.metric.stopListening(audioEngineContext.timer.getTestTime(), this.getCurrentPosition()); |
2004 } | 2006 } |
2005 this.interfaceDOM.stopPlayback(); | 2007 this.interfaceDOM.stopPlayback(); |
2008 this.playing = false; | |
2006 }; | 2009 }; |
2007 | 2010 |
2008 this.setupPlayback = function () { | 2011 this.setupPlayback = function () { |
2009 if (this.bufferNode === undefined && this.buffer.buffer !== undefined) { | 2012 if (this.bufferNode === undefined && this.buffer.buffer !== undefined) { |
2010 this.bufferNode = audioContext.createBufferSource(); | 2013 this.bufferNode = audioContext.createBufferSource(); |