Replace parameters by constant in code


#1

Let's say i have a dial, which goes into the math/*c, the outlet of which goes into inlet_i1 (frac32) of another object, call it O1. I've figured out that i need to set the dial on the math/*c object to 19.2 to get what i want. Now i want to eliminate the math/*c object from my patch, to save me some ui elements. Given that math/*c is
outlet_out= ___SMMUL(param_amp,inlet_in)<<1;,
i would replace inlet_i1 in the k-rate code of O1 by ___SMMUL(constant-number-19.2,inlet_i1)<<1.
Now, how do i figure out the correct constant-number-19.2?
I suppose this has to do with using integers instead of floats, and some fancy bit-shifting is needed, but i cannot figure out the receipe.

I suppose my general question is: if i have an object with a parameter p, and i know the value that i want for that parameter once and for all, how do i figure out the constant that would need to go into the code instead of param_p if i want to get rid of the parameter?


#2

go live with this patch:

and note down the hex number, it should be the one you enter in there. (convert with a hex to decimal tool if you want to enter the number in decimal)


#3

You can also do something like this, using bit shifting and a float:

__SMMUL( (int32t)(19.20f * (1 << 21)) ,inlet_i1)<<1.


#4

Thanks a million, guys!