Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1354:8605db97c241
Adding volume control interface object. Minor discrete layout format change.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Fri, 22 Jan 2016 11:10:33 +0000 |
parents | 41574c5bc5ee |
children | 5352a2adc6d1 |
comparison
equal
deleted
inserted
replaced
1353:41574c5bc5ee | 1354:8605db97c241 |
---|---|
783 this.preTestSurvey = null; | 783 this.preTestSurvey = null; |
784 this.postTestSurvey = null; | 784 this.postTestSurvey = null; |
785 this.stateIndex = null; | 785 this.stateIndex = null; |
786 this.currentStateMap = null; | 786 this.currentStateMap = null; |
787 this.currentStatePosition = null; | 787 this.currentStatePosition = null; |
788 this.currentTestId = 0; | 788 this.currentStore = null; |
789 this.stateResults = []; | |
790 this.timerCallBackHolders = null; | |
791 this.initialise = function(){ | 789 this.initialise = function(){ |
792 | 790 |
793 // Get the data from Specification | 791 // Get the data from Specification |
794 var pageHolder = []; | 792 var pageHolder = []; |
795 for (var page of specification.pages) | 793 for (var page of specification.pages) |
816 if (this.stateMap.length > 0) { | 814 if (this.stateMap.length > 0) { |
817 if(this.stateIndex != null) { | 815 if(this.stateIndex != null) { |
818 console.log('NOTE - State already initialise'); | 816 console.log('NOTE - State already initialise'); |
819 } | 817 } |
820 this.stateIndex = -1; | 818 this.stateIndex = -1; |
821 var that = this; | |
822 var aH_pId = 0; | |
823 for (var id=0; id<this.stateMap.length; id++){ | |
824 var name = this.stateMap[id].type; | |
825 var obj = document.createElement(name); | |
826 if (name == 'audioHolder') { | |
827 obj.id = this.stateMap[id].id; | |
828 obj.setAttribute('presentedid',aH_pId); | |
829 aH_pId+=1; | |
830 } | |
831 this.stateResults.push(obj); | |
832 } | |
833 } else { | 819 } else { |
834 console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); | 820 console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); |
835 } | 821 } |
836 }; | 822 }; |
837 this.advanceState = function(){ | 823 this.advanceState = function(){ |
868 this.currentStateMap = this.stateMap[this.stateIndex]; | 854 this.currentStateMap = this.stateMap[this.stateIndex]; |
869 if (this.currentStateMap.randomiseOrder) | 855 if (this.currentStateMap.randomiseOrder) |
870 { | 856 { |
871 this.currentStateMap.audioElements = randomiseOrder(this.currentStateMap.audioElements); | 857 this.currentStateMap.audioElements = randomiseOrder(this.currentStateMap.audioElements); |
872 } | 858 } |
873 storage.createTestPageStore(this.currentStateMap); | 859 this.currentStore = storage.createTestPageStore(this.currentStateMap); |
874 if (this.currentStateMap.preTest != null) | 860 if (this.currentStateMap.preTest != null) |
875 { | 861 { |
876 this.currentStatePosition = 'pre'; | 862 this.currentStatePosition = 'pre'; |
877 popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest); | 863 popup.initState(this.currentStateMap.preTest,storage.testPages[this.stateIndex].preTest); |
878 } else { | 864 } else { |
2789 } else { | 2775 } else { |
2790 this.curTimeSpan.textContent = '00:00'; | 2776 this.curTimeSpan.textContent = '00:00'; |
2791 } | 2777 } |
2792 }; | 2778 }; |
2793 }; | 2779 }; |
2794 | 2780 |
2781 this.volume = new function() | |
2782 { | |
2783 // An in-built volume module which can be viewed on page | |
2784 // Includes trackers on page-by-page data | |
2785 // Volume does NOT reset to 0dB on each page load | |
2786 this.valueLin = 1.0; | |
2787 this.valueDB = 0.0; | |
2788 this.object = document.createElement('div'); | |
2789 this.object.id = 'master-volume-holder'; | |
2790 this.slider = document.createElement('input'); | |
2791 this.slider.id = 'master-volume-control'; | |
2792 this.slider.type = 'range'; | |
2793 this.valueText = document.createElement('span'); | |
2794 this.valueText.id = 'master-volume-feedback'; | |
2795 this.valueText.textContent = '0dB'; | |
2796 | |
2797 this.slider.min = -60; | |
2798 this.slider.max = 12; | |
2799 this.slider.value = 0; | |
2800 this.slider.step = 1; | |
2801 this.slider.onmousemove = function(event) | |
2802 { | |
2803 interfaceContext.volume.valueDB = event.currentTarget.value; | |
2804 interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB); | |
2805 interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB+'dB'; | |
2806 audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin; | |
2807 } | |
2808 this.slider.onmouseup = function(event) | |
2809 { | |
2810 var storePoint = testState.currentStore.XMLDOM.children[0].getAllElementsByName('volumeTracker'); | |
2811 if (storePoint.length == 0) | |
2812 { | |
2813 storePoint = storage.document.createElement('metricresult'); | |
2814 storePoint.setAttribute('name','volumeTracker'); | |
2815 testState.currentStore.XMLDOM.children[0].appendChild(storePoint); | |
2816 } | |
2817 else { | |
2818 storePoint = storePoint[0]; | |
2819 } | |
2820 var node = storage.document.createElement('movement'); | |
2821 node.setAttribute('test-time',audioEngineContext.timer.getTestTime()); | |
2822 node.setAttribute('volume',interfaceContext.volume.valueDB); | |
2823 node.setAttribute('format','dBFS'); | |
2824 storePoint.appendChild(node); | |
2825 } | |
2826 | |
2827 this.object.appendChild(this.slider); | |
2828 this.object.appendChild(this.valueText); | |
2829 } | |
2795 // Global Checkers | 2830 // Global Checkers |
2796 // These functions will help enforce the checkers | 2831 // These functions will help enforce the checkers |
2797 this.checkHiddenAnchor = function() | 2832 this.checkHiddenAnchor = function() |
2798 { | 2833 { |
2799 for (var ao of audioEngineContext.audioObjects) | 2834 for (var ao of audioEngineContext.audioObjects) |