Beginner question

Post Reply
aintteyen
Posts: 7
Joined: Fri Jan 08, 2021 5:05 pm

Beginner question

Post by aintteyen »

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.
ColinP
Posts: 939
Joined: Mon Aug 03, 2020 7:46 pm

Re: Beginner question

Post by ColinP »

This 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.
aintteyen
Posts: 7
Joined: Fri Jan 08, 2021 5:05 pm

Re: Beginner question

Post by aintteyen »

ColinP wrote: Mon Jan 11, 2021 11:11 am This 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.
Basically the converting voltage to frequency was the thing that got me stumped. Thank you, I will try this.
User avatar
honki-bobo
Posts: 305
Joined: Sat Nov 09, 2019 1:18 pm

Re: Beginner question

Post by honki-bobo »

Check out this thread:
viewtopic.php?f=8&t=974#p3753
Image
Monkey Business Audio
Modules - Music - Twitter - YouTube
ColinP
Posts: 939
Joined: Mon Aug 03, 2020 7:46 pm

Re: Beginner question

Post by ColinP »

That thread actually confused me.

I can see that 55.0 * 2.0 ^ ( x + 0.25 ) produces, as shown in the screenshot, C5 with x = 3 but it took me several minutes to figure it out.

F = FZ * 2 ^ V

or

frequency = frequencyAtZeroVolts * pow( 2.0, voltage );

seems far easier to understand.
Post Reply

Return to “Module Designer”