Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1282:a918de498abc
Calibration through audioEngine audio output. Reference controls global volume for tests.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Tue, 29 Mar 2016 14:24:05 +0100 |
parents | b5db605914ab |
children | b24d861c96b3 |
comparison
equal
deleted
inserted
replaced
1281:f32c95ab5f21 | 1282:a918de498abc |
---|---|
3105 oscillator: audioContext.createOscillator(), | 3105 oscillator: audioContext.createOscillator(), |
3106 gain: audioContext.createGain(), | 3106 gain: audioContext.createGain(), |
3107 f: f0, | 3107 f: f0, |
3108 parent: this, | 3108 parent: this, |
3109 handleEvent: function(event) { | 3109 handleEvent: function(event) { |
3110 this.gain.gain.value = Math.pow(10,this.input.value/20); | 3110 var value = Math.pow(10,this.input.value/20); |
3111 if (this.f == 1000) { | |
3112 audioEngineContext.outputGain.gain.value = value; | |
3113 interfaceContext.volume.slider.value = this.input.value; | |
3114 } else { | |
3115 this.gain.gain.value = value | |
3116 } | |
3111 switch(event.type) { | 3117 switch(event.type) { |
3112 case "mouseenter": | 3118 case "mouseenter": |
3113 this.oscillator.start(0); | 3119 this.oscillator.start(0); |
3114 break; | 3120 break; |
3115 case "mouseleave": | 3121 case "mouseleave": |
3125 } | 3131 } |
3126 } | 3132 } |
3127 obj.root.className = "calibration-slider"; | 3133 obj.root.className = "calibration-slider"; |
3128 obj.root.appendChild(obj.input); | 3134 obj.root.appendChild(obj.input); |
3129 obj.oscillator.connect(obj.gain); | 3135 obj.oscillator.connect(obj.gain); |
3130 obj.gain.connect(audioContext.destination); | 3136 obj.gain.connect(audioEngineContext.outputGain); |
3131 obj.gain.gain.value = Math.random()*2; | 3137 obj.gain.gain.value = Math.random()*2; |
3132 obj.input.value = obj.gain.gain.value; | 3138 obj.input.value = obj.gain.gain.value; |
3133 obj.input.setAttribute('orient','vertical'); | 3139 obj.input.setAttribute('orient','vertical'); |
3134 obj.input.type = "range"; | 3140 obj.input.type = "range"; |
3135 obj.input.min = -6; | 3141 obj.input.min = -6; |
3156 for (var obj of this.calibrationNodes) { | 3162 for (var obj of this.calibrationNodes) { |
3157 var node = storage.document.createElement("calibrationresult"); | 3163 var node = storage.document.createElement("calibrationresult"); |
3158 node.setAttribute("frequency",obj.f); | 3164 node.setAttribute("frequency",obj.f); |
3159 node.setAttribute("range-min",obj.input.min); | 3165 node.setAttribute("range-min",obj.input.min); |
3160 node.setAttribute("range-max",obj.input.max); | 3166 node.setAttribute("range-max",obj.input.max); |
3161 node.setAttribute("gain-db",20*Math.log10(obj.gain.gain.value)); | |
3162 node.setAttribute("gain-lin",obj.gain.gain.value); | 3167 node.setAttribute("gain-lin",obj.gain.gain.value); |
3163 this.storeDOM.appendChild(node); | 3168 this.storeDOM.appendChild(node); |
3164 } | 3169 } |
3165 } | 3170 } |
3166 } | 3171 } |