Mercurial > hg > webaudioevaluationtool
comparison core.js @ 2191:dd5a8556235c
Calibration sliders update on mouse move trigger
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Tue, 29 Mar 2016 14:37:07 +0100 |
parents | 96988cb46d18 |
children | 6c819878ac85 |
comparison
equal
deleted
inserted
replaced
2190:96988cb46d18 | 2191:dd5a8556235c |
---|---|
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 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 } | |
3117 switch(event.type) { | 3110 switch(event.type) { |
3118 case "mouseenter": | 3111 case "mouseenter": |
3119 this.oscillator.start(0); | 3112 this.oscillator.start(0); |
3120 break; | 3113 break; |
3121 case "mouseleave": | 3114 case "mouseleave": |
3122 this.oscillator.stop(0); | 3115 this.oscillator.stop(0); |
3123 this.oscillator = audioContext.createOscillator(); | 3116 this.oscillator = audioContext.createOscillator(); |
3124 this.oscillator.connect(this.gain); | 3117 this.oscillator.connect(this.gain); |
3125 this.oscillator.frequency.value = this.f; | 3118 this.oscillator.frequency.value = this.f; |
3119 break; | |
3120 case "mousemove": | |
3121 var value = Math.pow(10,this.input.value/20); | |
3122 if (this.f == 1000) { | |
3123 audioEngineContext.outputGain.gain.value = value; | |
3124 interfaceContext.volume.slider.value = this.input.value; | |
3125 } else { | |
3126 this.gain.gain.value = value | |
3127 } | |
3126 break; | 3128 break; |
3127 } | 3129 } |
3128 }, | 3130 }, |
3129 disconnect: function() { | 3131 disconnect: function() { |
3130 this.gain.disconnect(); | 3132 this.gain.disconnect(); |
3145 obj.input.value = (Math.random()*12)-6; | 3147 obj.input.value = (Math.random()*12)-6; |
3146 } else { | 3148 } else { |
3147 obj.input.value = 0; | 3149 obj.input.value = 0; |
3148 obj.root.style.backgroundColor="rgb(255,125,125)"; | 3150 obj.root.style.backgroundColor="rgb(255,125,125)"; |
3149 } | 3151 } |
3150 obj.input.addEventListener("change",obj); | 3152 obj.input.addEventListener("mousemove",obj); |
3151 obj.input.addEventListener("mouseenter",obj); | 3153 obj.input.addEventListener("mouseenter",obj); |
3152 obj.input.addEventListener("mouseleave",obj); | 3154 obj.input.addEventListener("mouseleave",obj); |
3153 obj.gain.gain.value = Math.pow(10,obj.input.value/20); | 3155 obj.gain.gain.value = Math.pow(10,obj.input.value/20); |
3154 obj.oscillator.frequency.value = f0; | 3156 obj.oscillator.frequency.value = f0; |
3155 this.calibrationNodes.push(obj); | 3157 this.calibrationNodes.push(obj); |