Basic Automatic Volume Control

quoob's icon

Dear All,

I am trying to recreate a basic automatic volume control within Max. I am using a eternal mic input to pick up the noise in the room routed into a live.gain~ . On another channel I have a track playing off an play~ and buffer~ into a live.gain~.

What I am trying to achieve is to increase the music volume if the noise inside the room increases.

What I'd like to know is if I can take the output of the 5th outlet of both live.gain~ (which outputs dBs values) and feed it into a IF and create a statement like

"if ch1 is xdB louder than ch2 then increase ch2 of ndBs"  and vice versa  "if ch2 is xdB louder than ch1 then reduce ch1 of ndBs"

Is that even humanly possible? Unfortunately I am not a ninja in Max but when it comes to maths I'm a real donkey :/

Any ideas out there?

Thank

quoob's icon

Anyone?!
is it the topic not interesting enough? or it is incomprehensible way I have explained?

mzed's icon

Automatic gain control is possible, although it's tricky if you're outputting the sound into the room. If you turn up the sound, the room gets louder, so you turn up the sound some more, and ...hilarity ensues.

Max Patch
Copy patch and select New From Clipboard in Max.

I think your live gain idea is ok, although one object doesn't allow you to the gain of each channel individually. I might do something like this:

Probably you'll need more features to get the result you're after.

quoob's icon

Hi MZED, thank you very much for your feedback.

Here you can see where I am with this patch. But as you already guessed, what I am struggling with is the music played in the room being picked up as the actual noise to be compensated

What do you think about the use of the IF? Although, I guess the result would be the same just tackled from a different angle..?!

AVC_forum.maxpat
Max Patch
mzed's icon
Max Patch
Copy patch and select New From Clipboard in Max.

You could try removing some of the sound amplitude you're putting into the room from the amplitude you're evaluating, like:

This is rather hack-ish, but it might get you there. Filters on the input signal might be another possibility. It will be very difficult to get a scientifically precise result, but a little gain boost if the room gets loud should be possible.

Lou Terry's icon

Hi QUOOB,
Probably a bit late (6 years too late!), but if you're still wanting to know, I think I may have made something that works as an automatic volume controller in response to a mic (or other) input - I was having similar issues.
Let me know if it works for you/if you have any questions !

best of luck
Lou

Max Patch
Copy patch and select New From Clipboard in Max.

Lou Terry's icon

Also just a note: mine makes the output volume louder if the input is quiet and vice versa, but for what you're doing you'll want to swap the final two arguments of the map object around!