## mtof cents detuning math flawed?

May 9, 2012 at 1:52pm

# mtof cents detuning math flawed?

It’s not really a big deal, i’m just curious whether my math is flawed or max’ math is flawed

– Pasted Max Patch, click to expand. –
#63475
May 9, 2012 at 4:15pm

The example below shows the correct math, I think (assuming the U.S. standard of 440 Hz for A). There are very slight differences between the output of mtof and expr, but I’m guessing that that just has something to do with different implementations of the power function or something. The differences are pretty minuscule and should not be a problem in most cases (you have to stretch the flonum objects to be bigger in order to see the differences, which are on the order of a few 1/10,000ths of a Hz).

– Pasted Max Patch, click to expand. –
#228849
May 9, 2012 at 4:22pm
#228850
May 9, 2012 at 6:11pm

lol :)

sorry. thank you both.

#228851
May 10, 2012 at 4:33am

the mtof obejcts are using the “other” method, which is less accurate but faster.

#228852
May 11, 2012 at 8:24am

If you take the trouble to look at mtof.maxhelp, you will see the formula that mtof actually uses.

The two [expr]s are mathematically equivalent to within the accuracy of 6 digits. Chris’ formula is more accurate because the exponent of the pow() function is always calculated to full 64-bit precision. The formula used by mtof is more efficient because the constant portion of the function is precalculated. A classic efficiency vs. accuracy trade-off.

So, show of hands, please: who can hear the difference of frequency?

#228853
May 11, 2012 at 8:31am

“If you take the trouble to look at mtof.maxhelp, you will see the formula that mtof actually uses.”

That’s not actually true anymore. The max6 help file no longer contains the expr solution.

“So, show of hands, please: who can hear the difference of frequency?”

La Monte Young!

#228854
May 11, 2012 at 9:40am

peter: you can hear it when you mix the two methods in your patch, so it is good

#228855

You must be logged in to reply to this topic.