• ### Convert frequency to a linear -5/+5 scale

Hello,

I am trying to find a way to convert frequency into a linear scale going from -5 to +5 in float. The goal is to generate a frequency in hertz and onvert it to a float to get a control voltage. I tried entering the frequency value to pow, scale or exp with no success. Is there an object for that ? Or a mathemagic expression ? I never did any log/exp math, so I have no idea how to do it.

Thank you.

• Posts 7 | Views 1166
• @kosuke16 Linear should be easy I think.....

If you actually want a log curve you should insert a [pow 2] before the [/ 2000].....
Here it is used in the signal domain.... sweep-explained.zip
..... which will show you how to change the range to 20-20000 and let you hear the difference between linear and log response....
David.

• Thank you for your reply. It is in fact a log 2 that should be inserted before the scaling. I was pointed to that function on a dev forum mentionning its existence in C# and thought I would try it in PD. Here is the correct patch for what I am trying to achieve. I use 0.203 as it is the float I need to get one octave higher and it is the same between the different octaves so this works.

Hertz to volts.pd

• It isn't enough to convert Hz to linear. You also need to decide which frequency corresponds to -5 V, and which to +5.

Then divide your frequency by the Hz value for -5. Then you need the log to base (high Hz / low Hz). This can be done by:

// this is both steps: division and log
ln(freq / low) / ln(high / low)

Now you'll have a value from 0 to 1, which can easily be scaled onto the desired voltage range by doing that_value * 10 - 5.

On the phone so I can't build it out right now, but this formula will work.

hjh

• @kosuke16 You could also use [ftom] to convert the frequency to MIDI, then scale and shift the MIDI number to the range you want.

• You are right. I did the scaling by mesuring with a tuner and substracting the correct value to the final float. But anyway, the easiest way is to tune the synths everytime I would need to use them in a chromatic world, which is not always the case. I know it isn't an easy/quick approach of the issue, but at the same time, the patch is just for me, so I don't really care. And it is way easier to just turn a physical frequency knob to offset the synth than to calculate everything for every synth at only one frequency knob position and be stuck with that mighty and important knob in only one position.

TBH, so far the basic use I imagined for the patch isn't very interesting but it makes some very nice noises and textures where pitch accuracy isn't that important.

• @kosuke16 found this in the [chair] external and spent some time testing it with a (behringer fake k2) korg ms-20 just recently so I thought I'd share it.

Haven't tested the Linear CV yet to see if it matches up with midi - had to change the [/ ] amount for hertz per volt because 1 and 2 volts were based on C instead of A

simpleFrequencytoCV.pd

and here it was using the audio out for pitch detection and a cheap oscilliscope to measure the CV

Posts 7 | Views 1166
Internal error.

Oops! Looks like something went wrong!