我有网络音频 api 和 JQuery 旋钮库工作......但不完全。旋钮滑块控制输入滑块,但该值似乎没有传递给我想要影响的参数。
一个简单的例子见这里:
代码:
<input id="gain1" type="range" class="dial" >
<script>
document.getElementById('gain1').addEventListener('change', function() {
gainNode.gain.value = this.value;
});
$(function() {
var value = document.getElementById("gain1").value;
$(".dial").knob({ change : function (value) { }
})
});
context = new webkitAudioContext();
//Create oscillator object & params
oscillator = context.createOscillator(), oscillator.type = 2; oscillator.frequency.value = 200;
//Create gain object & params
gainNode = context.createGainNode(); gainNode.gain.value = 1;
//Connect devices
oscillator.connect(gainNode);
gainNode.connect(context.destination);
oscillator.start(0);
</script>