[wplug] Audio: Compression Utility?

Russ Schneider russpgh at stargate.net
Thu Jun 12 13:36:22 EDT 2003


I'm not talking about Ogg or MP3 type compression here, I'm talking 
about taking an audio file and compressing it, evening out the levels, 
preventing harsh spikes.

A google search came up rather bleak, flooded with ogg/mp3 type 
examples.  I was wondering if anyone on this list use a compression 
tool, hopefully something as simple as the following normalize tool 
someone shared with me:


#!/usr/bin/perl
# this takes all the files on the command line, and amplifies them all
# _by the same amount_ as much as possible without clipping.

foreach $file (@ARGV) {
     print "$file should be adjusted by ";
     open SOX, "-|", "nice sox \'$file\' -e stat -v 2>&1" or die;
     chomp($sox = <SOX>);
     close SOX;
     print "$sox.\n";
     $adjust = $sox if $adjust > $sox or not defined $adjust;
}
exit unless $adjust > 1;
print "Adjusting volume by $adjust for:\n";
foreach $file (@ARGV) {
     print "\t$file\n";
     system "nice", "sox", "-v", $adjust, $file,
            "-t", "wav", "$file.temp" and die;
     rename "$file.temp", $file or die;
}
print "done.\n";


-- 
___________________________________
Russ Schneider (a.k.a. Sugapablo)
http://www.sugapablo.com




More information about the wplug mailing list