Using scale to round off values into note frequencies.

astevens's icon

Hi, I wonder if anyone can give me some pointers.

I'm trying to take numerical values between 80 and 180 and convert them to frequency values of a c major scale, eg if the value 80 is input the note C 261.63hz is generated, 81 = D 293.66, 82 = E 329.63

Any help most appreciated.

brendan mccloskey's icon

Hi
[coll] is really the only way to do this with minimum fuss, although [itable] or maybe [multislider] could help toi

Brendan

Peter Castine's icon

[expr (($i1-79)*12)/7+59)] -> [mtof]

Integrating the MIDI-to-frequency conversion into the expr object is left as an exercise for the reader.

The basic technique is to use *integer* arithmetic. Multiplication with 12 followed by division with 7 maps sequential integers to a diatonic pattern (half step/step/step/half step/step/step/step). The rest is just figuring out offsets to get the mode and tonic you want.

Chris Muir's icon

Leaving aside the fact that there aren't 100 values of C Major, essentially you are trying to use integers as scale degrees.

I would tackle this as two parts: convert the integers into MIDI note numbers in the scale of your choosing. Then, use mtof or mtof~ to convert to frequency.

FWIW, I have a scale degree quantizer in my Scale Master total-overkill quantizer system, which can be found here: http://www.xfade.com/max/

Peter Castine's icon

Ah, Chris, it's only fourteen octaves. Maybe astevens wants his dog to enjoy the music, too!

Nice collection of scales.

astevens's icon

Thanks for all the tips, yes you're right, there aren't 100 values of the scale.

What a pickle eh...

Thanks again for your time chaps.