Mercurial > hg > webaudioevaluationtool
changeset 217:e69c08e35d83 Dev_main
Merge into dev_main
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Wed, 17 Jun 2015 15:42:56 +0100 |
parents | 3cc4088aa6d5 (diff) 0560fe84fde6 (current diff) |
children | c2f02c60b14f |
files | |
diffstat | 3 files changed, 171 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/ape.js Wed Jun 17 15:27:11 2015 +0100 +++ b/ape.js Wed Jun 17 15:42:56 2015 +0100 @@ -59,6 +59,94 @@ console.log('slider ' + id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id }; + // Bindings for interfaceContext + Interface.prototype.checkAllPlayed = function() + { + hasBeenPlayed = audioEngineContext.checkAllPlayed(); + if (hasBeenPlayed.length > 0) // if a fragment has not been played yet + { + str = ""; + if (hasBeenPlayed.length > 1) { + for (var i=0; i<hasBeenPlayed.length; i++) { + str = str + hasBeenPlayed[i]; + if (i < hasBeenPlayed.length-2){ + str += ", "; + } else if (i == hasBeenPlayed.length-2) { + str += " or "; + } + } + alert('You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.'); + } else { + alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.'); + } + return false; + } + return true; + } + + Interface.prototype.checkAllMoved = function() { + var audioObjs = audioEngineContext.audioObjects; + var state = true; + var strNums = []; + for (var i=0; i<audioObjs.length; i++) + { + if (audioObjs[i].metric.wasMoved == false) { + state = false; + strNums.push(i); + } + } + if (state == false) { + if (strNums.length > 1) { + var str = ""; + for (var i=0; i<strNums.length; i++) { + str = str + strNums[i]; + if (i < strNums.length-2){ + str += ", "; + } else if (i == strNums.length-2) { + str += " or "; + } + } + alert('You have not moved fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.'); + } else { + alert('You have not moved fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.'); + } + } + return state; + } + + Interface.prototype.checkAllCommented = function() { + var audioObjs = audioEngineContext.audioObjects; + var audioHolder = testState.stateMap[testState.stateIndex]; + var state = true; + if (audioHolder.elementComments) { + var strNums = []; + for (var i=0; i<audioObjs.length; i++) + { + if (audioObjs[i].commentDOM.trackCommentBox.value.length == 0) { + state = false; + strNums.push(i); + } + } + if (state == false) { + if (strNums.length > 1) { + var str = ""; + for (var i=0; i<strNums.length; i++) { + str = str + strNums[i]; + if (i < strNums.length-2){ + str += ", "; + } else if (i == strNums.length-2) { + str += " or "; + } + } + alert('You have not commented on fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.'); + } else { + alert('You have not commented on fragment ' + strNums[0] + ' yet. Please listen, rate and comment all samples before submitting.'); + } + } + } + return state; + } + // Bindings for audioObjects // Create the top div for the Title element @@ -353,8 +441,39 @@ function buttonSubmitClick() // TODO: Only when all songs have been played! { - hasBeenPlayed = audioEngineContext.checkAllPlayed(); - if (hasBeenPlayed.length == 0) { + var checks = specification.commonInterface.options; + var canContinue = true; + for (var i=0; i<checks.length; i++) { + if (checks[i].type == 'check') + { + switch(checks[i].check) { + case 'fragmentPlayed': + // Check if all fragments have been played + var checkState = interfaceContext.checkAllPlayed(); + if (checkState == false) {canContinue = false;} + break; + case 'fragmentFullPlayback': + // Check all fragments have been played to their full length + var checkState = interfaceContext.checkAllPlayed(); + if (checkState == false) {canContinue = false;} + console.log('NOTE: fragmentFullPlayback not currently implemented, performing check fragmentPlayed instead'); + break; + case 'fragmentMoved': + // Check all fragment sliders have been moved. + var checkState = interfaceContext.checkAllMoved(); + if (checkState == false) {canContinue = false;} + break; + case 'fragmentComments': + // Check all fragment sliders have been moved. + var checkState = interfaceContext.checkAllCommented(); + if (checkState == false) {canContinue = false;} + break; + } + + } + } + + if (canContinue) { if (audioEngineContext.status == 1) { var playback = document.getElementById('playback-button'); playback.click(); @@ -368,24 +487,7 @@ } } testState.advanceState(); - } else // if a fragment has not been played yet - { - str = ""; - if (hasBeenPlayed.length > 1) { - for (var i=0; i<hasBeenPlayed.length; i++) { - str = str + hasBeenPlayed[i]; - if (i < hasBeenPlayed.length-2){ - str += ", "; - } else if (i == hasBeenPlayed.length-2) { - str += " or "; - } - } - alert('You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.'); - } else { - alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.'); - } - return; - } + } } function convSliderPosToRate(slider)
--- a/core.js Wed Jun 17 15:27:11 2015 +0100 +++ b/core.js Wed Jun 17 15:42:56 2015 +0100 @@ -1201,6 +1201,7 @@ // Handles the decoding of the project specification XML into a simple JavaScript Object. this.interfaceType; + this.commonInterface; this.projectReturn; this.randomiseOrder; this.collectMetrics; @@ -1233,6 +1234,30 @@ } } + var commonInterfaceNode = setupNode.getElementsByTagName('interface'); + if (commonInterfaceNode.length > 0) { + commonInterfaceNode = commonInterfaceNode[0]; + } else { + commonInterfaceNode = undefined; + } + + this.commonInterface = new function() { + this.OptionNode = function(child) { + this.type = child.nodeName; + if (this.type == 'check') { + this.check = child.getAttribute('name'); + } + } + this.options = []; + if (commonInterfaceNode != undefined) { + var child = commonInterfaceNode.firstElementChild; + while (child != undefined) { + this.options.push(new this.OptionNode(child)); + child = child.nextElementSibling; + } + } + }; + var audioHolders = projectXML.getElementsByTagName('audioHolder'); for (var i=0; i<audioHolders.length; i++) { this.audioHolders.push(new this.audioHolderNode(this,audioHolders[i])); @@ -1333,6 +1358,21 @@ this.url = xml.getAttribute('url'); this.id = xml.id; this.parent = parent; + this.anchor = xml.getAttribute('anchor'); + if (this.anchor == 'true') {this.anchor = true;} + else {this.anchor = false;} + + this.reference = xml.getAttribute('reference'); + if (this.reference == 'true') {this.anchor = true;} + else {this.reference = false;} + + if (this.anchor == true && this.reference == true) { + console.log('ERROR - Cannot have one audioElement be both the reference and anchor!') + console.log(this); + console.log('Neither will be enabled'); + this.anchor = false; + this.reference = false; + } }; this.commentQuestionNode = function(xml) {
--- a/example_eval/project.xml Wed Jun 17 15:27:11 2015 +0100 +++ b/example_eval/project.xml Wed Jun 17 15:42:56 2015 +0100 @@ -34,6 +34,14 @@ <metricEnable>elementFlagMoved</metricEnable> <metricEnable>elementListenTracker</metricEnable> </Metric> + <interface> + <check name="fragmentPlayed"/> + <check name="fragmentFullPlayback"/> + <check name="fragmentMoved"/> + <check name="fragmentComments"/> + <anchor>20</anchor> + <reference>80</reference> + </interface> </setup> <audioHolder id='test-0' hostURL="example_eval/" sampleRate="44100" randomiseOrder='true' repeatCount='0' loop='true' elementComments='true'> <interface> @@ -44,7 +52,7 @@ <scale position="20">20</scale> <commentBoxPrefix>Comment on fragment</commentBoxPrefix> </interface> - <audioElements url="0.wav" id="0"/> + <audioElements url="0.wav" id="0" anchor='true'/> <audioElements url="1.wav" id="1"/> <audioElements url="2.wav" id="2"/> <audioElements url="3.wav" id="3"/>