PitchToRatio

Mar 31, 2009 at 11:25am

PitchToRatio

Hi,

In a context of audio sampling, i’m looking to map an information of pitch (be it MIDI or a frequency, but conversions are easy) into ratios, to use controlling audio playback speed.

the whole range would be centered on midinote 60 for a ratio of 1. (normal playback speed); an octave above (note 72) should correspond to a ratio of 2. and an octave below to 0.5

so, how to map the whole pitch range to ratios relating to midinote 60 . My maths knowledge is quite poor.

this should be a very common thing to do and seemed trivial to me but I got stuck. neither in MSP nor Max tutorials I could find an answer. Peter Elseas pitch tutorial got me on the track but Im still not quite there.

Any suggestion?
Thanks in advance.

Touche

#43121
Mar 31, 2009 at 1:05pm

Take the pitch through mtof and divide the result by the mtof of 60 (your reference).

_
johan

#154615
Mar 31, 2009 at 1:08pm

here you go, two objects is all you need:

max v2;
#N vpatcher 587 425 1187 825;
#P window setfont “Sans Serif” 9.;
#P flonum 60 188 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 60 151 118 196617 expr pow(2\,($f1/12));
#P newex 60 123 33 196617 – 60.;
#P user kslider 60 76 35 1 24 72 19 7 0 128 128 128 128 128 128 255 255 255 0 0 0 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 2 0;
#P connect 2 0 3 0;
#P pop;

regards,
klaas-jan govaart

#154616
Mar 31, 2009 at 1:12pm

Yep,

my math is indeed quite poor, and I thank you a lot.

Have a good day.

#154617

You must be logged in to reply to this topic.