Convert midi 0 -127 to frequency?
Hi So I am using the softube modular system lately and they don't have the option to enter specific values to a parameter as far I know and I have tried everything. This issue is with the Buchla 259 OSC So what I do is I map a max4live device to the freq of the osc through midi learn and the value of the buchla pitch is 27-7039.5 hz What I am trying to do is convert the 0-127(the value of the map control) to 27-7039.5 I tried with the scale object but that didn't work so I am wondering if you know any way I can do this so that when I input the frequency I want to tune the osc to it converts it to 0-127 for me to input to the midi mapper device I used?
Open the search facility in Max, type "MIDI to frequency" into the window, and hit return.
I don't have Softube Modular, but looking at a screenshot of the Buchla 259 it looks like the frequency control is not linear, but exponential. It is marked as going from 27.5 to 7040 by doubling 8 times, so...
Freq = 27.5 * 2 ^ (8 * Val / 127)
rearranging...
Val = Log2( Freq / 27.5) * 127 / 8
As there is no Log2 function in Max (I think?), we can convert that to natural logs easy enough;
Val = ( Ln( Freq / 27.5) / Ln(2)) * 127 / 8
However (1), that might not be very musical, because its splitting each octave into about 16 steps. So maybe it would be better to split each octave into 12 steps, but only using values 0 to 96 on the controller range. As 27.5 is a factor of 440, this would mean each of these values would result in the oscillator being tuned to music notes, each 1 semitone apart.
However (2), now that we got this far, we can see that in fact we could have just used the Max objects [mtof] and [ftom], but we would need to offset by 21 to get to the correct starting pitch.
Here is a patch with these implemented as [expr]. 16 divisions on the left, 12 divisions on the middle, and [mtof] / [ftom] on the right.
Regards,
Nick.
@ NICK HOLMES Thanks a lot man the one on the left seems to almost work when I input 440hz it tells me 63.5 I input it to the controller and it gives me 430hz in the buchla can anything be done for this?
Thanks again so much though for the amazing answer I have a lot of studying to do!
The problem is that the midi values are integers (whole numbers), and so 63.5 isn't valid. You could use 63, which will give you 430.5hz or 64 which will give you 449.7hz. That is what I meant by this not being very musical approach.
If you use either of middle or right examples (they are equivalent), a value of 48 will put you on exactly 440hz - indeed every possible integer value will be a musically "correct" pitch (but values from 97 to 127 will result in pitches above the maximum available on this module).
@ NICK HOLMES Thanks again so much for the help
Do you by any chance know of any device that I can map to a midi learn(in this case the buchla prinicipal osc pitch) and enter an exact value through there since ableton won't let me input a value in a midi learned parameter? so that I can bypass all this and set the osc to exactly 440hz?
Well, just add the VST to your track in Ableton, then use Configure Mode to pull the osc frequency back to a device parameter. It will then show up in your clips as an Envelope, and you can can adjust that envelope to precisely the correct values you need at any point in the clip (or on the timeline, if you are in Arrangement mode).
@ NICK HOLMES yes that works but now it shows the frequency in the envelope with a range of 0 -1 I was expecting for it to show in the exact hz
What's your ideal goal here - to be able to set the exact frequency of the oscillator, or to be able to set the musical note for the oscillator?
NICK HOLMES the exact frequency
softube has become quite popular during the last week.