CV input to volume module

Post Reply
Posts: 9
Joined: Thu Jun 13, 2019 7:11 am

CV input to volume module

Post by flyinghitcher » Mon Jun 24, 2019 12:51 pm

There is some fundamental examples missing in the develope examples, having made a volume module from the Programmer's Guide which works fine, I now want to turn it into something more useful, and to expand it to have more features.

Bypass function, panning, cv input, spring to mind. Nowhere in the 11 examples covers this. So is anyone brave enough to attempt to talk me though adding a CV input so it can at least be modulated by an LFO ?

User avatar
Posts: 86
Joined: Sat Aug 25, 2018 11:12 am

Re: CV input to volume module

Post by Captain » Mon Jun 24, 2019 6:08 pm

Is there something specific you don't understand, and/or did you already try something (but it didn't work)? In any case, modulating volume with CV would (at its simplest) work something like this:

1. Add an input jack to the module
2. Read its value in the ProcessSample() function (just like reading the value of the audio input jack)
3. Use that value to modulate the volume value (meaning, you combine the two values to create a new value) - how exactly you want to do it is up to you, but it's just basic math. The value coming from the input is usually between -5 and 5 (corresponding to the voltage values used in HW systems), but it can be just about anything.

For example, you could just add the values together, dividing the CV input value by 5 to crush it into the -1 to 1 range:

Code: Select all

newVolumeValue = oldVolumeValue + cvInputValue / 5;
This might result in a negative volume, which will flip the phase of the output sample. This might be cool, but if not, you can check to make sure the volume doesn't go below zero:

Code: Select all

if ( newVolumeValue < 0 ) {
  newVolumeValue = 0;
And finally you just multiply the output sample value with the new modulated volume, and send it to the output jack, just like in the example code.

Similarly, panning etc is just reading input values from jacks and knobs, adding and multiplying, and sending new values to output jacks.

Post Reply