This should be really simple.. shouldn't it?
I'm looking for a way to scale the result of combining a param (frac32.u.map) and an inlet (frac32.positive) to a positive integer between 0 and an arbitrary positive integer maximum value.
I've got as far as:
int32_t result = __USAT(param_a + inlet_b, 27);
In floating-point, you would do it like (super-simple):
result = val * out_max / in_max
but how do you do it in fixed-point?
I'm really sorry to ask such a stupid question. I know this stuff must be very basic. I'm trying to read around it, but nothing about fixed-point maths is making much sense to me right now, unfortunately.
a|x