Sunday, September 13, 2009

normalize all your movie audio on-the-fly with ALSA

I have a pretty large collection of ripped dvd movies.  Invariably, they all have different volumes, which can be very annoying.  I was just about to use mencoder to re-encode all the audio with normalized audio... and then I thought there must be a better way.  Sure enough, there is: http://alsa.opensrc.org/index.php/FAQ#Is_there_an_alsa_plugin_I_can_use_to_compress_or_normalize_my_audio_output_volume.3F

So I copied the section below into /etc/asound.conf:

pcm.ladcomp {
      type plug
      slave.pcm "ladcomp_compressor";
  }
 pcm.ladcomp_compressor {
      type ladspa
      slave.pcm "ladcomp_limiter";
      path "/usr/lib/ladspa";
      plugins [
          {
              label dysonCompress
              input {
                  #peak limit, release time, fast ratio, ratio
                  controls [0 1 0.5 0.99]
              }
          }
      ]
  }
 pcm.ladcomp_limiter {
      type ladspa
      slave.pcm "plughw:0,0";
      path "/usr/lib/ladspa";
      plugins [
          {
              label fastLookaheadLimiter
              input {
               #InputGain(Db) -20 -> +20 ; Limit (db) -20 -> 0 ; Release time (s) 0.01 -> 2
               controls [ 20 0 0.8  ]
              }
          }
     ]
  }
These plugins need to be installed though: apt-get install swh-plugins 
Now the tricky part, getting your programs to actually use this stuff. You have to tell your program to use the ladcomp alsa device. Mplayer and Xine are pretty easy, you can just type it in a box in the gui. However, Gnome's Movie Player (Totem) is a bit trickier. Google to the rescue: http://www.mail-archive.com/gnome-list@gnome.org/msg02589.html

Basically open Configuration Editor and change
system -> gstreamer -> 0.10 -> default) changing the key "musicaudiosink" from "alsasink" to "alsasink device=ladcomp"

All my movies seem to be nearly the same volume now. I setup xine to use it as well, and played a DVD and it seemed to be just a bit louder than movie files, so I'll have to look more into exactly what this filter is doing, maybe it is not reducing loud volume, but just cranking up low volume?

Tuesday, September 8, 2009

smp usb flash-on-root corruption issue

I suspect (but can't really confirm) that having this 3-processor phenom chip and booting to USB flash, combined with suspend-to-ram seems to somehow result in an extremely corrupted filesystem. Booting with kernel option "nosmp" seems to completely resolve the problem... so, that is good and sucky at the same time. Aha! Hot-plug to the rescue! I just stuck this script in /etc/pm-tools/sleep.d/99cpu

#!/bin/sh
. "${PM_FUNCTIONS}"

case "$1" in
hibernate|suspend)
echo 0 > /sys/devices/system/cpu/cpu1/online
echo 0 > /sys/devices/system/cpu/cpu2/online
;;
thaw|resume)
echo 1 > /sys/devices/system/cpu/cpu1/online
echo 1 > /sys/devices/system/cpu/cpu2/online
;;
*)
;;
esac



We'll have to see if it solves the problem, but it does indeed remove my 2 processors before suspend and then adds them back again after everything is back up. Kinda sad but I don't feel like upgrading my kernel or messing around this more than I have to :-)

Debian Lenny
Kernel 2.6.26-2-686 #1 SMP

Sunday, September 6, 2009

Linux Wireless Fun

LinkSys WPM54G PCI wireless card:

apt-get install firmware-ralink
it should work now

edit /etc/pm/config.d/defaults
and add/change:
SUSPEND_MODULES="rt61pci"

now you should be able to suspend the computer and not hang on resume