How do you use onControl(number,value)?



  • function onControl(number, value)
    {
    	v = Knob.getValue();
    
    	if (v < third)
    	{
    		changeKeyColor(red);
    	}
    	else if(inRange(v,third,third*2))
    	{
    		changeKeyColor(yellow);
    	}
    	else
    	{
    		changeKeyColor(blue);
    	}
    }
    
    

    What's up with the (number, value)? What do you do when you have multiple controls? I would have guessed that number is the control ID and value is the control value, but it doesn't seem to work like that.



  • Sorry, 'number' is a bit outdated as parameter name - it is the actual interface as variable and 'value' is the current value (so you don't need Knob.getValue()). So multiple controls can be used like this:

    	if(number == Button)
    	{
    		// Do something with button
    	}
    	else if(number == Knob)
    	{
    		// Do something with Knob
    		// Also: Knob.getValue() == value
    		Console.print(value);
    	}
    
    

    I'll probably change that parameter name to "control" or something…


 

2
Online

353
Users

1.1k
Topics

7.6k
Posts