## Convert Hz ratios to diatonic ratios [solved]

Sep 04 2018 | 3:47 pm
Hallo fellow Maxers, While I head off and do my own quick research - of which this forum is one major part - what is the formula for splitting the Hz octave (e.g. 220Hz - 440Hz) into mean/well tuned tones and semitones?
Context: in my granulator I have a pitch factor slider (-4 <--> +4), which slides across pitch. I'd like to have it step across pitch as a diatonic pitch shifter, by tones and semitones; I'd like to try the major scale first, or maybe any tonal steptwise pitch set that splits the octave. I
Many thanks Brendan (ps, mid research: can is open , worms are everywhere)

• Sep 04 2018 | 4:01 pm
-ish
• Sep 04 2018 | 8:05 pm
i would just shift the input range so that the lower limit in Hz becomes 60 ... ftom ... scale to whatever you need.
for other than chromatic i would convert chromatic to myscale as a last step (because i already have that ready) (but i am afraid you would prefer to have your controller reflecting the distances already, right?)
• Sep 04 2018 | 8:15 pm
& use float for your slider, especially for the conversion to diatonic.
• Sep 05 2018 | 6:20 am
I had thought about using [ftom], but how I would implement it is unclear to me. I am using the pitch factor slider to affect the pitch of 'live' audio input, where a value of 1 = no pitch shift, 0.5 = octave down and 2 = octave up. I should have clarified that I'm not really seeking Hz to semitones conversion, it's Hz ratios to semitones that I'm after.
• Sep 05 2018 | 8:47 am
to convert semitone steps into a pitch scalar, I use the following formula:
[expr pow(2, \$f1/12), where \$f1 is a +/- integer
;)
• Sep 05 2018 | 8:49 am
(pics or it didn't happen)
• Sep 05 2018 | 3:05 pm
i love solving such puzzles (and i usually have all requried parts alredady) but i still dont fully understand the original application. :) so we start with GUI slider from -4 to 4, which represents octaves, right? whats next? what other variables and constants are mandatory and how should the output look like? why do Hz matter at all - cant most be done linear?
• Sep 05 2018 | 3:50 pm
Are you trying to reproduce different historical temperaments or microtonal and just intonation ratios? Either way, if I understood it well, I think the most flexible way is to be able to import tuning description files. Maybe you're looking for something like this? http://sevish.com/2014/how-to-play-microtonal-scales-on-a-maxmsp-synth/
• Sep 05 2018 | 5:58 pm
Hi Roman and Felipe, the pitch ratio slider was used to multiply the pitch of a granular time/pitch stretcher, so that 1 = no shift, 0.5 = -1 octave, 2 = +1 octave. Using floating point values we get a glissando effect when moving the pitch scalar (it was a little counterintuitive anyway: starting in the middle and lowering the pitch scalar from 1 towards zero causes a pitch drop, then continuing into negative values gradually raises the pitch but with 'reversed' grains). In order to make it a little more 'musical' I decided to use semitone increments instead of glissando (and I added a 'reverse grain direction' toggle), so now my slider goes from -3 to +3 octaves, which to me is a little more intuitive. Sorry for not being clearer, and I probably muddied the water by asking for a specific formula as [expr pow(2, \$f1/12)] does exactly what I want: semitones input = pitch ratio output.
Thanks gents ( short demo here, if you like https://www.youtube.com/watch?v=HyPHeqjXSH0 )
• Sep 05 2018 | 6:01 pm
Just to clarify: I am multiplying the grain frequency by a pitch scalar, shrinking or growing the grain causes a shift in pitch: 1000/(grainDur*pitchScalar) = Hz)
HTH
• Sep 05 2018 | 8:51 pm
so that 1 = no shift, 0.5 = -1 octave, 2 = +1 octave ... you can probably avoid this ratio stuff when there is an mtof later. but as long as it works...
-110 (linear mapping version)
• Sep 06 2018 | 10:32 am
@Felipe, I'll probably just use a [coll] for a variety of pitch collections ;)