Reputation: 3470
I have two knobs, I would like to control dynamically the value of the first one when moving the second one.
so far I have: (First Knob)
$('#inf-knob').knobRot({
classes: ['inf-knob'],
frameWidth: 250,
frameHeight: 250,
frameCount: 100,
detent: false,
discreteSteps: false,
stepCount: 0,
minimumValue: 0,
maximumValue: 2,
dragMultiplier: 0.01,
hideInput: true,
});
$('#inf-knob').on('knobdrag', function(e){
//called until mouse button released
var dial = (500 * $('#inf-knob').val()).toFixed(1);
document.getElementById('freqmain').value = dial + " Hz";
document.getElementById('freqmain2').value = dial;
});
(Second Knob Should Change the first one dynamically when moved)
$('#black-knob').on('knobdrag', function(e){
gainNode.gain.value = this.value;
console.log(this.value * 2);
$('#inf-knob').val(this.value * 2);
});
I have also tried using:
document.getElementById('inf-knob').value = this.value;
with no results.
What am I Missing?
Thanks
Upvotes: 0
Views: 379
Reputation: 5224
As the Document of KnobRot states , you should use :
To return the value of the specified knob:
$('myselector').knobRot('get')
To set the value of the specified knob, or knobs (will work with a collection):
$('myselector').knobRot('set', value)
And then you need to trigger KnobRot
refresh. So in your case you can use it as :
$('#black-knob').knobRot({
}).on('knobdrag', function(e){
console.log(this.value * 2);
$('#inf-knob').knobRot('set', this.value);
$('#inf-knob').trigger('knobrefresh');
});
P.S
Upvotes: 1