Regulating audio output levels

Forum rules
Before you post please read how to get help
User avatar
cabbagetreemo
Level 1
Level 1
Posts: 15
Joined: Fri Mar 31, 2017 2:36 am
Location: New Zealand

Regulating audio output levels

Postby cabbagetreemo » Thu Sep 28, 2017 10:01 pm

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?

User avatar
Misko_2083
Level 1
Level 1
Posts: 17
Joined: Mon Jan 12, 2015 10:17 am

Re: Regulating audio output levels

Postby Misko_2083 » Fri Sep 29, 2017 7:20 pm

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.

User avatar
Termy
Level 3
Level 3
Posts: 170
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Regulating audio output levels

Postby Termy » Sun Oct 01, 2017 9:37 pm

Check out mp3gain, or rather, easymp3gain-gtk. I think it pretty much covers that one. The normalize-audio package also seems interesting.
Here to help.

User avatar
jimallyn
Level 16
Level 16
Posts: 6982
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Regulating audio output levels

Postby jimallyn » Sun Oct 01, 2017 10:03 pm

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.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
cabbagetreemo
Level 1
Level 1
Posts: 15
Joined: Fri Mar 31, 2017 2:36 am
Location: New Zealand

Re: Regulating audio output levels

Postby cabbagetreemo » Mon Oct 02, 2017 1:18 am

Thanks for all the responses, it will take me some time to try all of these solutions and see what works best


Return to “Scripts & Bash”