Posted: Fri Jan 08, 2021 5:30 pm
So i recently started using Module Designer and so far i have built my first LFO and oscillator, however i really need some help on how to implement v/oct input.
A place to discuss Cherry Audio and Voltage Modular
Basically the converting voltage to frequency was the thing that got me stumped. Thank you, I will try this.ColinP wrote: ↑Mon Jan 11, 2021 11:11 amThis is one of those things that I would have thought was super easy to find sample code for but a quick google reveals nothing very useful. And I must confess that this is something I've never coded myself but kind of just assumed was simple.
Someone else here can probably come up with better advice but I think you could start with the Java.lang.Math pow() method to convert voltage to frequency.
Something like frequency = pow( 2.0, voltage ).
This produces the 1 V/Octave curve so 0 V = 1 Hz, 1 V = 2 Hz, 2 V = 4 Hz, 3 V = 8 Hz and so on. Then you'd scale it so that the frequencies were in the range you wanted. Unfortunately there's no accepted standard for what pitch 0 V represents but most people choose either C0 or C2.
On modern CPUs pow() might not be as expensive as it used to be but one simple optimisation would be to only call pow() when the voltage changes rather than every sample.
As I said, I've never done this and am kind of surprised that it's not well documented. I don't have the time to look at this in more depth but hopefully another developer has already done this and can chip in with wiser words and maybe a snippet of source code.