Pitch shift formula

IvnOs's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi.
At this moment i'm working on calculator patch which will allow to work with different values. But i can't figure it out how to calculate an amount of pitch shift in percentage and st required to change tempo of loops from "BPM1" to "BPM2".
A this moment i have something like this:
Percentage value of pitch shift = ((BPM1 - BPM2)/BPM2)*100
And to translate % to St, i'm just dividing %/0.12
But it is totaly wrong... And i can't even understand where i'm wrong...

Peter Castine's icon

Have you tried looking at the help files for mtof and/or ftom? They include equivalent expr formulae for converting frequency to "pitch" (in terms of MIDI notes). There's still a bit of work to go from your "percentage of pitch shift" to pitch, but this should put you on the right path.

IvnOs's icon

Oh, thanks.
I forgot about such a nice objects. That's realy made my calculations easear.

Max Patch
Copy patch and select New From Clipboard in Max.

But i've already found a little problem: mtof working just with integer values of semitones, which makes calculations not so accurate as if it were calculated with cent values...
Here is what i get just for Semitone values:

mzed's icon
Max Patch
Copy patch and select New From Clipboard in Max.

presto, floating point:

IvnOs's icon

Thanks. =)
It's so hard to be noob =((

Roman Thilenius's icon

the 0. thing is true for most objects, and even long time users sometimes run into this trap. :)

also, in dont think [mtof] will be of much help when you want "cents" as a result.
the conversion from playspeed to midi note numbers has nothing to do with frequency (in Hertz), you can calculate that the direct way from BPM to cent offset much easier.
you´d just have to define the original playspeed and the original key as default, then do some simple math to convert changed values for the BPM setting to new note numbers/cents (dont know offhand now)

IvnOs's icon