Mercurial > hg > webaudioevaluationtool
changeset 483:a275f9689af6 Dev_main
Adding volume control interface object. Minor discrete layout format change.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 22 Jan 2016 11:10:33 +0000 |
parents | 6281b02dcb58 |
children | 44d20bccf36b |
files | core.css core.js interfaces/discrete.js |
diffstat | 3 files changed, 75 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/core.css Sat Jan 16 14:51:02 2016 +0000 +++ b/core.css Fri Jan 22 11:10:33 2016 +0000 @@ -98,3 +98,24 @@ position: relative; background-color: #000; } + +div#master-volume-holder { + width: 250px; + height: 25px; + float: left; +} + +input#master-volume-control { + width: 200px; + height: 25px; + float: left; + margin: 0px; + padding: 0px; +} + +span#master-volume-feedback { + width: 45px; + height: 25px; + margin-left: 5px; + float: left; +} \ No newline at end of file
--- a/core.js Sat Jan 16 14:51:02 2016 +0000 +++ b/core.js Fri Jan 22 11:10:33 2016 +0000 @@ -785,9 +785,7 @@ this.stateIndex = null; this.currentStateMap = null; this.currentStatePosition = null; - this.currentTestId = 0; - this.stateResults = []; - this.timerCallBackHolders = null; + this.currentStore = null; this.initialise = function(){ // Get the data from Specification @@ -818,18 +816,6 @@ console.log('NOTE - State already initialise'); } this.stateIndex = -1; - var that = this; - var aH_pId = 0; - for (var id=0; id<this.stateMap.length; id++){ - var name = this.stateMap[id].type; - var obj = document.createElement(name); - if (name == 'audioHolder') { - obj.id = this.stateMap[id].id; - obj.setAttribute('presentedid',aH_pId); - aH_pId+=1; - } - this.stateResults.push(obj); - } } else { console.log('FATAL - StateMap not correctly constructed. EMPTY_STATE_MAP'); } @@ -870,7 +856,7 @@ { this.currentStateMap.audioElements = randomiseOrder(this.currentStateMap.audioElements); } - storage.createTestPageStore(this.currentStateMap); + this.currentStore = storage.createTestPageStore(this.currentStateMap); if (this.currentStateMap.preTest != null) { this.currentStatePosition = 'pre'; @@ -2791,7 +2777,56 @@ } }; }; - + + this.volume = new function() + { + // An in-built volume module which can be viewed on page + // Includes trackers on page-by-page data + // Volume does NOT reset to 0dB on each page load + this.valueLin = 1.0; + this.valueDB = 0.0; + this.object = document.createElement('div'); + this.object.id = 'master-volume-holder'; + this.slider = document.createElement('input'); + this.slider.id = 'master-volume-control'; + this.slider.type = 'range'; + this.valueText = document.createElement('span'); + this.valueText.id = 'master-volume-feedback'; + this.valueText.textContent = '0dB'; + + this.slider.min = -60; + this.slider.max = 12; + this.slider.value = 0; + this.slider.step = 1; + this.slider.onmousemove = function(event) + { + interfaceContext.volume.valueDB = event.currentTarget.value; + interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB); + interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB+'dB'; + audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin; + } + this.slider.onmouseup = function(event) + { + var storePoint = testState.currentStore.XMLDOM.children[0].getAllElementsByName('volumeTracker'); + if (storePoint.length == 0) + { + storePoint = storage.document.createElement('metricresult'); + storePoint.setAttribute('name','volumeTracker'); + testState.currentStore.XMLDOM.children[0].appendChild(storePoint); + } + else { + storePoint = storePoint[0]; + } + var node = storage.document.createElement('movement'); + node.setAttribute('test-time',audioEngineContext.timer.getTestTime()); + node.setAttribute('volume',interfaceContext.volume.valueDB); + node.setAttribute('format','dBFS'); + storePoint.appendChild(node); + } + + this.object.appendChild(this.slider); + this.object.appendChild(this.valueText); + } // Global Checkers // These functions will help enforce the checkers this.checkHiddenAnchor = function()
--- a/interfaces/discrete.js Sat Jan 16 14:51:02 2016 +0000 +++ b/interfaces/discrete.js Fri Jan 22 11:10:33 2016 +0000 @@ -309,7 +309,6 @@ function resizeWindow(event) { // Called on every window resize event, use this to scale your page properly - var numObj = document.getElementsByClassName('track-slider').length; var totalHeight = (numObj * 66)-30; document.getElementById('scale-holder').style.width = window.innerWidth-220 + 'px'; @@ -322,6 +321,8 @@ audioEngineContext.audioObjects[i].interfaceDOM.resize(event); } } + document.getElementById('slider-holder').style.height = totalHeight + 'px'; + document.getElementById('slider').style.height = totalHeight + 70 + 'px'; drawScale(); }