Gain matching

Hi I am after a solution to this problem:

I have two audio-rate inputs. Either one might be louder than the other, and what I would like to be able to do is match the volume of the second input to the first. I know I can get use an envelope follower to get me a fair part of the way there but then I need to know how to use the value coming out of the way envelope follower such that no matter whether signal 2 is louder or quieter than signal 1 it ends up at the same volume.

Hi @pgatt,
as always, I wonder if I grasp the question, but I post a screenshot with sort of a gain balancer.
I’m using 2 simple VCO’s to feed the attenuverter, but the audio source could both be live inputs, or samples. Moving the gain knobs of the 8vert module, you should get the matched gains in the third scope.

1 Like

Thanks heaps, put me pretty much on the right track!

1 Like

To match a signal B to a signal A, what you want to do is apply a gain of envelope(A) / envelope(B) to signal B. I don’t know a module that performs division, but perhaps it exists or you can write one with Frank Buss Formula or VCV Prototype. Obviously, if signal B is silent, its envelope will be 0, so the division cannot be performed, so you’ll need some safety code like if (B == 0.0) return 0.

1 Like

Thanks for replying Andew, much appreciated. I actually got there with a bunch of VCV Unity’s in avg mode in the end

I’m not sure how that could have worked. You’ll need the division in there somewhere to “normalize” the signal against its envelope before applying the gain of the other signal’s envelope.

The arithmetic modules from Submarine can do that.

1 Like

This got me interested :slight_smile:


Nice. Now try it with your voice and a drumbeat to make a sort of one-band vocoder.

@Vortico @stoermelder I see it. That’s the the way to go! @pgatt Good if Unity was of use to your needs, but take into account that Andrew and Ben depicted the exact solution to your original requisite!

It may not have worked - I could be wrong. I will do some more fiddling and post in here later. Thanks for the further information Andrew and Ben, will definitely have a play with the methods you instructed!

1 Like

I think I may have cheated a little bit and used the same voltage sent to the VCA CV and then compressed based on that value.