II.3.5. Writing Control Event Handler

From the previous volume level control example, rather than directly access the control[0].value inside the processing function, we can write a handler that compute an intermediate variable called gain and gainRange. Without these intermediate variables, we have to compute the control[0].value from 0-127 integer values into 0.0-1.0 (floating point) and convert control[1].value to gain range value (floating point) at every new sample data.

To write the handler, we have to define the handler function void onControlChange(int controlIndex) inside the effectModule descendant class. Wee need to add the intermediate variables gain and gainRange as well. Here is the example code:

As you can see, the gain and gainRange variables have been added to the class at line#7 and line #8, and the handler onControlChange at line #14. The handler function is implemented at line #92, and now the process() function accounts both gain and gainRange control variables to scale the output signal level (line #117,#118).

Back to Table of ContentsBuy BSCORE Dev Pedal PCBBuy BSCORE ModuleBuy BSCORE Dev Pedal