Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2310:426995e02e79
Fix for #43. Added scale range check enforcement
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 29 Apr 2016 11:40:06 +0100 |
parents | e4a2a39838db |
children | 483bd6573747 |
comparison
equal
deleted
inserted
replaced
2308:64be32cd1c31 | 2310:426995e02e79 |
---|---|
1093 element.exportXMLDOM(storePoint); | 1093 element.exportXMLDOM(storePoint); |
1094 } | 1094 } |
1095 pageXMLSave(storePoint.XMLDOM, this.currentStateMap); | 1095 pageXMLSave(storePoint.XMLDOM, this.currentStateMap); |
1096 storePoint.complete(); | 1096 storePoint.complete(); |
1097 }; | 1097 }; |
1098 | |
1099 this.getCurrentTestPage = function() { | |
1100 if (this.stateIndex >= 0 && this.stateIndex< this.stateMap.length) { | |
1101 return this.currentStateMap; | |
1102 } else { | |
1103 return null; | |
1104 } | |
1105 } | |
1098 } | 1106 } |
1099 | 1107 |
1100 function AudioEngine(specification) { | 1108 function AudioEngine(specification) { |
1101 | 1109 |
1102 // Create two output paths, the main outputGain and fooGain. | 1110 // Create two output paths, the main outputGain and fooGain. |
2781 alert(str); | 2789 alert(str); |
2782 console.log(str); | 2790 console.log(str); |
2783 this.storeErrorNode(str); | 2791 this.storeErrorNode(str); |
2784 return false; | 2792 return false; |
2785 }; | 2793 }; |
2794 this.checkScaleRange = function(min, max) { | |
2795 var page = testState.getCurrentTestPage(); | |
2796 var audioObjects = audioEngineContext.audioObjects; | |
2797 var state = true; | |
2798 var str = "Please keep listening. "; | |
2799 var minRanking = Infinity; | |
2800 var maxRanking = -Infinity; | |
2801 for (var ao of audioObjects) { | |
2802 var rank = ao.interfaceDOM.getValue(); | |
2803 if (rank < minRanking) {minRanking = rank;} | |
2804 if (rank > maxRanking) {maxRanking = rank;} | |
2805 } | |
2806 if (minRanking*100 > min) { | |
2807 str += "At least one fragment must be below the "+min+" mark."; | |
2808 state = false; | |
2809 } | |
2810 if (maxRanking*100 < max) { | |
2811 str += "At least one fragment must be above the "+max+" mark." | |
2812 state = false; | |
2813 } | |
2814 if (!state) { | |
2815 console.log(str); | |
2816 this.storeErrorNode(str); | |
2817 alert(str); | |
2818 } | |
2819 return state; | |
2820 } | |
2786 | 2821 |
2787 this.storeErrorNode = function(errorMessage) | 2822 this.storeErrorNode = function(errorMessage) |
2788 { | 2823 { |
2789 var time = audioEngineContext.timer.getTestTime(); | 2824 var time = audioEngineContext.timer.getTestTime(); |
2790 var node = storage.document.createElement('error'); | 2825 var node = storage.document.createElement('error'); |