# HG changeset patch # User Nicholas Jillings # Date 1432463584 -3600 # Node ID 94b91d63e286b50e18fb6525f8576a675e55fa04 # Parent b260edc72d1c7c9f6c02030dc09d0ad1a7236fca Possible fix for Bug #1238. audioObject metric collection now controlled by the audioObjects themselves for timer information. Lastclicked and sliderPlayed functions no longer used. diff -r b260edc72d1c -r 94b91d63e286 ape.js --- 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"; diff -r b260edc72d1c -r 94b91d63e286 core.js --- 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; } }; }