Mercurial > hg > webaudioevaluationtool
changeset 110:94b91d63e286
Possible fix for Bug #1238. audioObject metric collection now controlled by the audioObjects themselves for timer information. Lastclicked and sliderPlayed functions no longer used.
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Sun, 24 May 2015 11:33:04 +0100 |
parents | b260edc72d1c |
children | f89182a5f28d |
files | ape.js core.js |
diffstat | 2 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ape.js Sun May 24 10:51:41 2015 +0100 +++ b/ape.js Sun May 24 11:33:04 2015 +0100 @@ -263,6 +263,11 @@ function loadTest(id) { + + // Reset audioEngineContext.Metric globals for new test + audioEngineContext.metric.lastClicked = -1; + audioEngineContext.metric.data = -1; + // Used to load a specific test page var textXML = testXMLSetups[id]; @@ -333,7 +338,7 @@ loopPlayback = false; } audioEngineContext.loopPlayback = loopPlayback; - + loopPlayback = false; // Create AudioEngine bindings for playback if (loopPlayback) { audioEngineContext.play = function() { @@ -491,7 +496,7 @@ audioEngineContext.play(); // Get the track ID from the object ID var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99! - audioEngineContext.metric.sliderPlayed(id); + //audioEngineContext.metric.sliderPlayed(id); audioEngineContext.selectedTrack(id); // Currently playing track red, rest green document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
--- a/core.js Sun May 24 10:51:41 2015 +0100 +++ b/core.js Sun May 24 11:33:04 2015 +0100 @@ -175,9 +175,16 @@ this.play = function(startTime) { this.bufferNode = audioContext.createBufferSource(); + this.bufferNode.owner = this; this.bufferNode.connect(this.outputGain); this.bufferNode.buffer = this.buffer; this.bufferNode.loop = audioEngineContext.loopPlayback; + if (this.bufferNode.loop == false) { + this.bufferNode.onended = function() { + this.owner.metric.listening(audioEngineContext.timer.getTestTime()); + } + } + this.metric.listening(audioEngineContext.timer.getTestTime()); this.bufferNode.start(startTime); this.played = true; }; @@ -187,6 +194,7 @@ { this.bufferNode.stop(0); this.bufferNode = undefined; + this.metric.listening(audioEngineContext.timer.getTestTime()); } }; @@ -278,6 +286,7 @@ this.listenedTimer = 0; this.listenStart = 0; + this.listenHold = false; this.initialPosition = -1; this.movementTracker = []; this.wasListenedTo = false; @@ -299,13 +308,15 @@ this.listening = function(time) { - if (this.listenStart == 0) + if (this.listenHold == false) { this.wasListenedTo = true; this.listenStart = time; + this.listenHold = true; } else { this.listenedTimer += (time - this.listenStart); this.listenStart = 0; + this.listenHold = false; } }; }