Volume normalization

From MythTV Official Wiki
Jump to: navigation, search

This page describes some methods to enable volume normalization on the fly, i.e., dynamic range compression.

Pulse Audio

This method will use the alsa LADSPA plugin named dyson compress to compress the range of the audio.

configure pulse audio

first you need to determine the name of the output to normalize:

pacmd list-sinks | grep -A 1 index

my result:

    index: 0
	name: <alsa_output.pci-0000_01_05.1.hdmi-stereo>
--
  * index: 1
	name: <alsa_output.pci-0000_03_06.0.analog-stereo>

I am using the analog device (index 1)

Next you need to edit your default.pa file

sudo nano /etc/pulse/default.pa 

and add the following lines

### custom sink for DRC
.ifexists module-ladspa-sink.so
.nofail
load-module module-ladspa-sink sink_name=ladspa master=alsa_output.pci-0000_03_06.0.analog-stereo plugin=dyson_compress_1403 label=dysonCompress control=0,1,0.5,0.99
.fail
.endif

The last options on the control flag:

control=0,1,0.5,0.99

set the Peak limit (in dB), Release time, Fast compression ratio, and Compression ratio, respectively.

meaning of settings

There are four setting for the dyson compress

  • Peak limit (in dB) – Controls the desired limit of the output signal in dB's. [Range -30 to 0]
  • Release time (in seconds) – Controls the time taken for the compressor to relax its gain control over the input signal [Range 0 to 1]
  • Fast compression ratio – This will determine how much the audio is made more dense. 0.5 is equivalent to 2:1 compression. 1.0 is equiv to inf:1 compression. [Range 0 to 1]
  • Compression ratio – [Range 0 to 1]

The amount of gain reduction is determined by ratio: a ratio of 4:1 means that if input level is 4 dB over the threshold, the output signal level will be 1 dB over the threshold. The gain (level) has been reduced by 3 dB (wikipedia).

restart pulse audio

pulseaudio -k
pulseaudio -D

setup as default sink

pacmd list-sinks | grep -A 1 index

my result:

    index: 0
	name: <alsa_output.pci-0000_01_05.1.hdmi-stereo>
--
  * index: 1
	name: <alsa_output.pci-0000_03_06.0.analog-stereo>
--
    index: 2
	name: <ladspa>

edit file

sudo nano /etc/pulse/default.pa 
set-default-sink 2

restart pulse again, and the asterisk should have move to index 2, our ladspa filtered volume:

    index: 0
	name: <alsa_output.pci-0000_01_05.1.hdmi-stereo>
--
    index: 1
	name: <alsa_output.pci-0000_03_06.0.analog-stereo>
--
  * index: 2
	name: <ladspa>

See also