Mercurial > hg > webaudioevaluationtool
diff core.js @ 1637:fb6354c5d3cf
Fixed metric collection, listening time, for looping sources
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Wed, 27 May 2015 18:53:34 +0100 |
parents | 9c186f1b068c |
children | 917676cbdcc8 |
line wrap: on
line diff
--- a/core.js Wed May 27 18:10:56 2015 +0100 +++ b/core.js Wed May 27 18:53:34 2015 +0100 @@ -521,18 +521,30 @@ // When stopeed, the buffer node is deleted and recreated with the stored buffer. this.buffer; + this.loopStart = function() { + this.outputGain.gain.value = 1.0; + this.metric.startListening(audioEngineContext.timer.getTestTime()); + } + + this.loopStop = function() { + if (this.outputGain.gain.value != 0.0) { + this.outputGain.gain.value = 0.0; + this.metric.stopListening(audioEngineContext.timer.getTestTime()); + } + } + 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; + this.bufferNode.onended = function() { + this.owner.metric.stopListening(audioEngineContext.timer.getTestTime()); + }; if (this.bufferNode.loop == false) { - this.bufferNode.onended = function() { - this.owner.metric.listening(audioEngineContext.timer.getTestTime()); - }; + this.metric.startListening(audioEngineContext.timer.getTestTime()); } - this.metric.listening(audioEngineContext.timer.getTestTime()); this.bufferNode.start(startTime); this.played = true; }; @@ -542,7 +554,7 @@ { this.bufferNode.stop(0); this.bufferNode = undefined; - this.metric.listening(audioEngineContext.timer.getTestTime()); + this.metric.stopListening(audioEngineContext.timer.getTestTime()); } }; @@ -658,14 +670,20 @@ this.movementTracker[this.movementTracker.length] = [time, position]; }; - this.listening = function(time) + this.startListening = function(time) { if (this.listenHold == false) { this.wasListenedTo = true; this.listenStart = time; this.listenHold = true; - } else { + } + } + + this.stopListening = function(time) + { + if (this.listenHold == true) + { this.listenedTimer += (time - this.listenStart); this.listenStart = 0; this.listenHold = false;