Frequencies and CV, converting back and forth in Lua (math math math)

Hey all, hoping someone out there has done the homework so I can copy it. :slight_smile:

I’d like to take a CV reading on a crow input and do some math on the frequency in hz that CV represents, then pump the result out of the crow outputs.

I’m hoping there’s an equation somewhere describing the relationship between cv and the frequency in hz that is already solved for cv and for frequency.

I searched around on the internet and found something that might be close:

freq = 55.0*2^(cv+.25)

When I tried to use it in my Lua script (and learned about math.log(n) along the way) the results weren’t what I was expecting. So I’m not sure if the equation is wrong (or more likely my solving for cv).

My hope is to do the following:

  1. get the input voltage from crow
  2. convert that input voltage to frequency
  3. do some math on the frequency (multiply by 3, for example)
  4. convert the mathed up frequency back to control voltage
  5. send that control voltage on a crow output

What I could use a hand with (or pointer to something to read etc) is the equation that describes how CV maps to frequency.

Thanks for any and all help and direction!

ah heck yeah, music maths!

  • any MIDI note number divided by 12 is how the pitch is expressed in voltage (assuming volt per octave)
  • so voltage * 12 should get you the corresponding MIDI note on any measured voltage
  • MIDI to Hz from the norns docs:
(440 / 32) * (2 ^ ((note_value - 9) / 12))

so in total, i’d start with this pair:

local volt_to_midi = incoming_volt * 12 -- you can do other transformations around this, if you want
local midi_to_hz = (440 / 32) * (2 ^ ((volt_to_midi - 9) / 12)) -- you can redefine for A by changing 440!

does that get you closer?

6 Likes

I’ll fire it up and give it a go. Thanks!