Page 1 of 1

Regulating audio output levels

Posted: Thu Sep 28, 2017 10:01 pm
by cabbagetreemo
I have an idea for a project which would regulate the audio levels such that any clip which has fluctuating volume (either intentionally or through poor mixing) would be made to sound as though it has fixed volume (obviously this should be easy to switch off in case one wants to hear the fluctuations in the intentional case).
My idea would be to compute the power spectral density of the audio using some fft algorithm at regular time intervals and integrate the result to find some proxy for the total volume (to get fancy one may consider weighting the integral with frequency response curves for a given set of speakers and the human ear but this is beyond the initial scope of this idea) and then either multiply the time domain waveform by some calculated factor such that the actual output volume matches some predefined level or automatically adjust the output volume in Mint to achieve the same result.

The fact that I do not know how one would go about this notwithstanding, I see two ways this might be done:
1. Calculations are done 'on the fly' which would work as long as the time intervals are greater than the expected calculation time.
2. Calculations are done for the whole clip before anything is played, this would presumably introduce a 'buffer' at the start of the clip but may be helpful for keeping things in sync, particularly if video is included.

If I were to go with option 2, then I could just precalculate everything for locally stored files but I'm not sure if this would be possible for web based content. So perhaps it would be preferable to go with option 1 and somehow 'catch' the audio on its way to the speakers which would introduce some delay line effect and therefore also require associated video to be caught and held to keep things synchronised.

So my questions are:
Is this feasible?
Has it already been done? (If so, can I download a script from somewhere?)
Feasibility aside, is this an idea people find interesting?

Re: Regulating audio output levels

Posted: Fri Sep 29, 2017 7:20 pm
by Misko_2083
There is an old thread on archlinux forum https://bbs.archlinux.org/viewtopic.php?id=99185
I know mplayer had an option to compress/limit audio output on the fly. Maybe mpv can do that too.

Re: Regulating audio output levels

Posted: Sun Oct 01, 2017 9:37 pm
by Termy
Check out mp3gain, or rather, easymp3gain-gtk. I think it pretty much covers that one. The normalize-audio package also seems interesting.

Re: Regulating audio output levels

Posted: Sun Oct 01, 2017 10:03 pm
by jimallyn
This will probably do what you want:


http://www.omgubuntu.co.uk/2017/06/inst ... ubuntu-ppa


You could also install Jack and JackRack and have a bunch of effects available. For material you have stored on your hard drive, install Audacity, open the file, and edit as you like.

Re: Regulating audio output levels

Posted: Mon Oct 02, 2017 1:18 am
by cabbagetreemo
Thanks for all the responses, it will take me some time to try all of these solutions and see what works best