On Tue, 25 Feb 2014 21:57:56 +0100
Kristian Amlie <kristian@xxxxxxxxxx> wrote:
On 23/02/14 12:16, Will Godfrey wrote:
As far as I can see there are at least 3 places where AddSynth filtering is
handled and Cal has made a lot of changes with regard to variable names -
all
of which make perfect sense of course!
Also there are a number of places where he's replaced something like:
GlobalPar.PFilterVelocityScale / 127.0 * 6.0 // velocity sensing
with:
GlobalPar.PFilterVelocityScale / 127.0f * 6.0f // velocity sensing
Is the latter just a more correct way of presenting a float value, or is it
possible that the compiler would treat these differently?
It is possible. Compilers generally convert each operand to the "best"
type of either operand. Which one is best is decided (roughly) by this
hierarchy:
- long double
- double
- float
- int
- short
- char
I see from the definition of PFilterVelocityScale that this is a char
variable, which has a *very* small range. So it's possible that all
numbers are converted to char before doing the math, which is
potentially very bad. By explicitly stating that those numbers are
floats, we increase the range and resolution of the calculation a lot.