Auto-Gain?
-
Im trying to conceptualize how to add an auto make-up gain feature that listens to the input audio over a few seconds, averages a max peak value then adjusts a gain knob.
So far I have a scriptnode with global cables getting peak data for L+R master output channels. Thats ready to read data. Im not that good at dealing with Buffers yet. Im guessing we have to fill a buffer of a certain length then use the api's I seen about getting peak values.
Can anyone point me in the right direction please?
Here's the flow:
- Click "auto-gain"
- Play a few seconds of audio
- Buffer collects peak values
- Math/ average peak values
- return average peak value.
- Adjust volume to pre-defined output.
ie. User sets desired output to be "-6db" , plays the track, output adjusted to match "-6db".
Thanks for any help!