changeset 2909:e2b241c88b74

ITU-R BS.1116 compliant template
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Tue, 01 Aug 2017 10:09:26 +0100
parents 9c26e579e64d
children becd7e8e0a3a
files interfaces/mushra.js js/core.js test_create/test_core.js tests/templates/itur1116.xml
diffstat 4 files changed, 49 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/interfaces/mushra.js	Tue Aug 01 09:13:57 2017 +0100
+++ b/interfaces/mushra.js	Tue Aug 01 10:09:26 2017 +0100
@@ -179,7 +179,7 @@
             audioObject.bindInterface(orNode);
         } else {
             // Create a slider per track
-            var label = interfaceContext.getLabel(labelType, index, audioHolderObject.labelStart);
+            var label = element.label || interfaceContext.getLabel(labelType, index, audioHolderObject.labelStart);
             var sliderObj = new sliderObject(audioObject, label);
 
             if (typeof audioHolderObject.initialPosition === "number") {
--- a/js/core.js	Tue Aug 01 09:13:57 2017 +0100
+++ b/js/core.js	Tue Aug 01 10:09:26 2017 +0100
@@ -1216,6 +1216,39 @@
     this.currentStore = null;
     this.initialise = function () {
 
+        function randomiseElements(page) {
+            // Get the elements which are fixed / labelled
+            var fixed = [],
+                or = [],
+                remainder = [];
+            page.audioElements.forEach(function (a) {
+                if (a.label.length > 0 || a.postion !== undefined) {
+                    fixed.push(a);
+                } else if (a.type === "outside-reference") {
+                    or.push(a);
+                } else {
+                    remainder.push(a);
+                }
+            })
+            if (page.poolSize > 0 || page.randomiseOrder) {
+                page.randomiseOrder = true;
+                if (page.poolSize === 0) {
+                    page.poolSize = page.audioElements.length;
+                }
+                page.poolSize -= fixed.length;
+                remainder = pickSubPool(remainder, page.poolSize);
+            }
+            // Randomise the remainders
+            if (page.randomiseOrder) {
+                remainder = randomiseOrder(remainder);
+            }
+            fixed = fixed.concat(remainder);
+            page.audioElements = fixed.concat(or);
+            page.audioElements.forEach(function (a, i) {
+                a.position = i;
+            });
+        }
+
         // Get the data from Specification
         var pagePool = [];
         specification.pages.forEach(function (page) {
@@ -1253,17 +1286,7 @@
             page.presentedId = i;
             this.stateMap.push(page);
             var elements = page.audioElements;
-            if (page.poolSize > 0 || page.randomiseOrder) {
-                page.randomiseOrder = true;
-                if (page.poolSize === 0) {
-                    page.poolSize = elements.length;
-                }
-                elements = pickSubPool(elements, page.poolSize);
-            }
-            if (page.randomiseOrder) {
-                elements = randomiseOrder(elements);
-            }
-            page.audioElements = elements;
+            randomiseElements(page);
             storage.createTestPageStore(page);
             audioEngineContext.loadPageData(page);
         }, this);
@@ -1325,23 +1348,6 @@
             popup.hidePopup();
             if (this.currentStateMap === null) {
                 this.currentStateMap = this.stateMap[this.stateIndex];
-                // Find and extract the outside reference
-                var elements = [],
-                    ref = [];
-                var elem = this.currentStateMap.audioElements.pop();
-                while (elem) {
-                    if (elem.type == "outside-reference") {
-                        ref.push(elem);
-                    } else {
-                        elements.push(elem);
-                    }
-                    elem = this.currentStateMap.audioElements.pop();
-                }
-                elements = elements.reverse();
-                if (this.currentStateMap.randomiseOrder) {
-                    elements = randomiseOrder(elements);
-                }
-                this.currentStateMap.audioElements = elements.concat(ref);
 
                 this.currentStore = storage.testPages[this.stateIndex];
                 if (this.currentStateMap.preTest !== undefined) {
--- a/test_create/test_core.js	Tue Aug 01 09:13:57 2017 +0100
+++ b/test_create/test_core.js	Tue Aug 01 10:09:26 2017 +0100
@@ -440,7 +440,7 @@
 }]);
 AngularInterface.controller("page", ['$scope', '$element', '$window', function ($s, $e, $w) {
     $s.schema = $w.specification.schema.querySelector("element[name=\"page\"]");
-    $s.page.label = "default";
+    $s.page.label = $s.page.label || "default";
     $s.addInterface = function () {
         $s.page.addInterface();
     };
--- a/tests/templates/itur1116.xml	Tue Aug 01 09:13:57 2017 +0100
+++ b/tests/templates/itur1116.xml	Tue Aug 01 10:09:26 2017 +0100
@@ -13,6 +13,11 @@
             </metric>
             <interface>
                 <interfaceoption type="check" name="fragmentMoved" />
+            </interface>
+        </setup>
+        <page id="training" randomiseOrder="true" repeatCount="0" loop="true" synchronous="true" position="0" label="capital">
+            <interface>
+                <title>Quality</title>
                 <scales>
                     <scalelabel position="100">Imperceptible</scalelabel>
                     <scalelabel position="75">Perceptible but not annoying</scalelabel>
@@ -21,18 +26,20 @@
                     <scalelabel position="0">Very annoying</scalelabel>
                 </scales>
             </interface>
-        </setup>
-        <page id="training" randomiseOrder="true" repeatCount="0" loop="true" synchronous="true" position="0">
-            <interface>
-                <title>Quality</title>
-            </interface>
             <audioelement url="0.wav" id="training-A" type="reference" label="A" position="0" />
             <audioelement url="1.wav" id="training-1" />
             <audioelement url="0.wav" id="training-2" />
         </page>
-        <page id="test-0" randomiseOrder="true" repeatCount="0" loop="true" synchronous="true" position="0">
+        <page id="test-0" randomiseOrder="true" repeatCount="0" loop="true" synchronous="true" position="0" label="capital">
             <interface>
                 <title>Quality</title>
+                <scales>
+                    <scalelabel position="100">Imperceptible</scalelabel>
+                    <scalelabel position="75">Perceptible but not annoying</scalelabel>
+                    <scalelabel position="50">Slightly annoying</scalelabel>
+                    <scalelabel position="25">Annoying</scalelabel>
+                    <scalelabel position="0">Very annoying</scalelabel>
+                </scales>
             </interface>
             <audioelement url="0.wav" id="test-0-A" type="reference" label="A" position="0" />
             <audioelement url="1.wav" id="test-0-1" />