Mercurial > hg > webaudioevaluationtool
changeset 1395:41054721d136
MUSHRA: Set the initial position of sliders using the <audioHolder> attribute initial-position using integer 0 to 100
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Thu, 17 Dec 2015 16:10:58 +0000 |
parents | 8325139a738a |
children | cfbe1252ff4c |
files | core.js mushra.js |
diffstat | 2 files changed, 24 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/core.js Thu Dec 17 15:58:16 2015 +0000 +++ b/core.js Thu Dec 17 16:10:58 2015 +0000 @@ -1847,6 +1847,7 @@ this.elementComments = undefined; this.outsideReference = null; this.loudness = null; + this.initialPosition = null; this.preTest = new parent.prepostNode("pretest"); this.postTest = new parent.prepostNode("pretest"); this.interfaces = []; @@ -1871,6 +1872,18 @@ { this.loudness = parent.loudness; } + if (typeof xml.getAttribute('initial-position') === "string") + { + var xmlInitialPosition = Number(xml.getAttribute('initial-position')); + if (isNaN(xmlInitialPosition) == false) + { + if (xmlInitialPosition > 1) + { + xmlInitialPosition /= 100; + } + this.initialPosition = xmlInitialPosition; + } + } if (xml.getAttribute('loudness') != null) { var XMLloudness = xml.getAttribute('loudness'); @@ -1946,7 +1959,9 @@ AHNode.setAttribute("loop",this.loop); AHNode.setAttribute("elementComments",this.elementComments); if(this.loudness != null) {AHNode.setAttribute("loudness",this.loudness);} - + if(this.initialPosition != null) { + AHNode.setAttribute("loudness",this.initialPosition*100); + } for (var i=0; i<this.interfaces.length; i++) { AHNode.appendChild(this.interfaces[i].encode(root));
--- a/mushra.js Thu Dec 17 15:58:16 2015 +0000 +++ b/mushra.js Thu Dec 17 16:10:58 2015 +0000 @@ -137,8 +137,14 @@ // Create a slider per track audioObject.interfaceDOM = new sliderObject(audioObject); - // Distribute it randomnly - audioObject.interfaceDOM.slider.value = Math.random(); + if (typeof audioHolderObject.initialPosition === "number") + { + // Set the values + audioObject.interfaceDOM.slider.value = audioHolderObject.initalPosition; + } else { + // Distribute it randomnly + audioObject.interfaceDOM.slider.value = Math.random(); + } sliderBox.appendChild(audioObject.interfaceDOM.holder); audioObject.metric.initialised(audioObject.interfaceDOM.slider.value);