Closed interstar closed 3 years ago
OK. I found a formula and ended up adapting it.
In my VCO object ...
set_midi_note = function(self,mn)
a = 440 -- frequency of A (common value is 440Hz)
n = (a / 32) * math.pow(2,((mn - 9) / 12)) -- (2 ** ((mn - 9) / 12))
self:set_freq(n)
self.phase = 0
end
When working at a low level, I find "cycle per sample" easier to use than "cycle per second" (aka Hertz). To convert between the two, you multiply or divide by the samplerate. Sine Organ is one example of how to use this kind of value (the noteFreq
field is populated using midi.noteToFreq
). Maybe providing frequencies in Hertz would be better for clarity though!
I'm having a bit of trouble figuring out midi.noteToFreq
I expected I'd have a function to turn MIDI notes into Hertz, as I already do the calculation to turn Hertz into the phaser delta in my synth.
But the documentation says :
I'm guessing that means frequency is samples to the power of -1. Ie. 1 / frequency in samples?
But how do I calculate the Hz from that? Or how do I use it exactly?