68

In different audio sources the level of sounds are different. It's very annoying to set the level of sound on almost every media content. Sometimes, when previously you had something quiet, you had to adjust it louder and after some time you want to play another media - bang! it unexpectedly breaks your headphones, the sound is so loud!

So, is there some plugin/feature which can automatically adjust the level of sound on every media content?

2

5 Answers 5

43

Adjusting sound level with a LADSPA plugin

To obtain a fairly normalized sound output level independent of the input level we may use a LADSPA-plugin to filter the sound output through PulseAudio.

As a minimum, we need a compressor plugin such as the dysonCompressor from the swh-plugins which need to be installed if not yet present.

After having found out the name of our default sink with

pacmd list-sinks

and the exact name of the plugin as it is stored in /usr/lib/ladspa/ (with my system here dyson_compress_1403) we can issue the following command

pacmd load-module module-ladspa-sink sink_name=ladspa_sink master=<alsa_output> plugin=dyson_compress_1403 label=dysonCompress control=0,1,0.5,0.99

Replace <alsa_output> with the exact name of the output sink (in my system this was alsa_output.pci-0000_00_14.2.analog-stereo).

The compressed output can now be heard on the newly created output sink ladspa_sink accessible from the Sound Settings menu.

enter image description here

Control settings for the compressor plugin are as follows: peak limit, release time, fast ratio, ratio. See in the plugin documentation for more details, defaults and minimal resp maximal values for these controls.

To avoid clipping of playback we may also combine this plugin with a limiter after compression. We may use the fast_lookahead_limiter for this with the master sink being now our just created lasdpa_sink from above:

pacmd load-module module-ladspa-sink sink_name=ladspa_normalized master=ladspa_sink plugin=fast_lookahead_limiter_1913 label=fastLookaheadLimiter control=10,0,0.8

Source: settings above were adapted to pulseaudio from brien's blog on miscfits

6
  • very cool! by selecting the output entry above we can promptly hear the difference! btw, cmd to remove them just for tests pacmd unload-module module-ladspa-sink, and to select the normalized sink pacmd set-default-sink ladspa_normalized Feb 8, 2016 at 20:33
  • I am experiencing a glitch, the volume suddenly gets too quiet, like it have been modified to prevent loudness, and then I have to up the volume one step to hear what ppl are speaking, but then it gets a bit loud.. I wonder if we could have some kind of "equalizer normalizer", where all the frequencies are dynamically managed to let us hear music, sound effects and people speech all properly normalized and never very loud. Any tip/idea? Feb 13, 2016 at 22:01
  • 1
    @AquariusPower I guess it is because the plugin tries to guess in advance what the volume might be... this appears to be hard coded for 5 ms. You can try with another limiter e.g. from the TAP set: tap-plugins.sourceforge.net/ladspa/limiter.html that has a 12.5 ms latency or another compressor (e.g. MLT mltframework.org/bin/view/MLT/FilterLadspa-1072)... haven't tried that however.
    – Takkat
    Feb 13, 2016 at 23:32
  • mmm... I must add that, the problem I experienced seems to have happened only on a single youtube video that by luck I was playing just after applying ladspa; this is working great for everything else, including games! thx on these other tips also, I will check them! Feb 22, 2016 at 2:39
  • 2
    Change the control parameter to reflect control=-12,1,0.5,0.99 using -12 instead of 0. This means that only sound above -12 dB will be compressed (softened), which typically includes anything louder than voices / conversation. Make this change if you're finding that, when watching movies (e.g. RED 2 on NetFlix), the vocals are still too quiet compared to the explosions.
    – Coder Guy
    Sep 29, 2016 at 6:02
20

Takkat's solution is good, but here's a variation which is simpler and permanent.

  1. apt-get install swh-plugins
  2. Cut and paste the following into a file called ~/.config/pulse/default.pa:

    .nofail
    .include /etc/pulse/default.pa
    load-module module-ladspa-sink  sink_name=ladspa_sink  plugin=dyson_compress_1403  label=dysonCompress  control=0,1,0.5,0.99
    load-module module-ladspa-sink  sink_name=ladspa_normalized  master=ladspa_sink  plugin=fast_lookahead_limiter_1913  label=fastLookaheadLimiter  control=10,0,0.8
    set-default-sink ladspa_normalized
    
  3. Run pulseaudio -k or log out and back in again

Normalization will automatically be turned on for all subsequent logins.

6
  • What's the effect of omitting the "master" parameter? What's configured as the sink's master in that case? Jan 27, 2018 at 22:32
  • Hi Nicolay: My reading of the source code indicates that a NULL string is the same as "@DEFAULT_SINK@". (See also line 216, or so, of namereg.c). But why do you ask? If there are any problems with my solution, I'd like to fix them.
    – hackerb9
    Jan 29, 2018 at 1:06
  • Hi, I started using the solution in this answer to be able to switch between speakers and headphones without unplugging them, and in the Sound control panel, I only get the filtered outputs for the speakers. Any idea about how to make it work for the headphones output as well? Jul 15, 2019 at 16:12
  • I'm not sure, but perhaps you need to run two filters, one for each output. Or, maybe the normalization needs to happen after splitting headphones/speakers into separate outputs.
    – hackerb9
    Jul 16, 2019 at 20:43
  • Actually, I was wrong, sorry about that : what happens is that if I select the filtered output, I have sound coming through both headphones and speakers, which I don’t want. I haven’t figured out how to separate it Jul 24, 2019 at 16:16
3

Volume normalization is present in SMPlayer. Goto software center and download this awesome player, then enable volume normalization under audio options :)

1

Earlier I was also having audio normalization issues while playing movies on my VLC media player but few searches over Internet I was able to find a perfect solution for this and I have shared it below so that you can also benefit from it....

Audio Normalization VLC Fix / Audio Out of Sync VLC Fix

2
  • 2
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Jan 25, 2016 at 23:32
  • The linked page shows a few settings - VLC has "Volume Normalizer" Filter and support for "Replay Gain".
    – handle
    Jan 5, 2020 at 18:17
1

Along with an alternative, I have some comments to the solutions above that suggest using the dysoncompressor.

From the manual:

 2.37  Dyson compressor (dysonCompress, 1403)
Peak limit (dB)
Controls the desired limit of the output signal in dB's.
Release time (s)
Controls the time taken for the compressor to relax its gain control over the input signal.
Fast compression ratio
I have no clear idea what this controls.
Compression ratio
I have no clear idea what this controls. 

http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html#tth_sEc1.1

The author of the package doesn't know what the last two values control. So how could you all say what you should input as the last two values?

The plugin itself suggests control=0,0.25,0.5,0.5

$ analyseplugin /usr/lib/ladspa/dyson_compress_1403.so

Plugin Name: "Dyson compressor"
Plugin Label: "dysonCompress"
Plugin Unique ID: 1403
Maker: "Steve Harris <[email protected]>"
Copyright: "GPL"
Must Run Real-Time: No
Has activate() Function: Yes
Has deactivate() Function: No
Has run_adding() Function: Yes
Environment: Normal or Hard Real-Time
Ports:  "Peak limit (dB)" input, control, -30 to 0, default 0
    "Release time (s)" input, control, 0 to 1, default 0.25
    "Fast compression ratio" input, control, 0 to 1, default 0.5
    "Compression ratio" input, control, 0 to 1, default 0.5
    "Input" input, audio
    "Output" output, audio

I would even suggest that you try one of the other compressors, that seem better documented, like sc4.

load-module module-ladspa-sink  sink_name=ladspa_sink  plugin=sc4_1882 label=sc4  control=0,101.125,401,0,1,3.25,0
1
  • 1
    This alternative compressor sounds better to me, but the control parameters listed in the answer do not seem to have any effect. The threshold level is set to 0 (never compresses) and ratio is set 1 (even if it compressed, it would use 1:1, which does not change the signal). You could use something like control=0,101.125,401,-22,10,3.25,0 instead, so that anything above -22dB gets compressed 1:10. These are intentionally somewhat extreme values so that one can hear the effect of the filter and then can finetune the values.
    – Zoltan
    Nov 2, 2018 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .