Forums > MaxMSP

Midi Dial Info to Frequency

Feb 26 2010 | 5:21 pm

Very simple one I hope… I have a Korg NanoKontrol and I want to make a very simple patch where by turning one of the knobs creates an increase in the frequency of a sine wave. So, as a crude example:

[midiin] > [dial] > [number] > [cycle~]> [dac~]

…gives me this, but only up to 127. How do I convert the incoming midi numerical info so that 127 equals whatever I decide the upper frequency of the cycle~ should be?

Feb 26 2010 | 5:40 pm

You can use the [scale] object. [scale 0 127 100 5000] would for instance take a number from 0 to 127 (your midi value) and scale it between 100 and 5000. If you want to change the range of the output values, use scale’s inlets for this.

Of course, you can also do it by simple mathematical calculations. Divide your midi number by 127. (giving you values from 0. to 1.), then multiply it with your desired upper frequency. For example:
[dial] > [/ 127.] > [* 5000.] > [cycle~]

Of course, one thing you need to accept with any of these methods is that you won’t be able to leave behind the "grid" of 7 bit resolution of the midi value. Even if you spread the values to range from 0 Hz to 10000 Hz, there will still be 128 distinct steps and not a continuous glissando, if you move your dial.

Feb 26 2010 | 9:09 pm

That being said you can smooth the data with the line object or use pitch bend data which will have a much higher resolution.

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > MaxMSP