Hey there,
i am trying to write a debounce object similar to debouncing button input on a microcontroller .
My starting point is the object logic/change speedlim
This is its code
<![CDATA[
if ((pval != inlet_in)&(!ptrig)) {
outlet_trig = 1;
pval = inlet_in;
ptrig = 1 << 27;
} else {
if (ptrig>0) {
ptrig -= param_d >> 7;
} else ptrig = 0;
outlet_trig = 0;
}
]]>
Can someone explain what these bitshift operations have to do with a time interval? (param_d is the control knob on the objects gui and it sets a time)
My aim is to write something like this.
- the first time the boolean input goes to 1 the output goes to 1 and stays on until the input was off a certain time intervall. so that a flickering input doenst interrupt the on state at the output.
In Addition to that im wondering if there is a possiblity to use global variables to store settings for the patch.
Is there anything like the f object in pd?
regards,
Flub