I wrote this one for applying albumgain on mp3s with auto
clipping protection. You'll need to run it once for each group
of mp3s that are part of an album. If the suggested gain clips,
it will step down until it no longer clips. Hope it helps.


Code:
--------------------
    #!/usr/bin/perl -w
  
  unless (@ARGV) {
  die "usage: $0 mp3file [ mp3file ... ]\n";
  }
  
  $clipped = 0;
  
  @quotedfiles = map { qq("$_") } @ARGV;
  
  $listout = `mp3gain -o @quotedfiles`;
  
  ($albumgain) = ($listout =~ /^"Album"\s+(\S+)/m);
  @maxsample     = ($listout =~ /^.+?\t-*\d+\s+\S+\s+(\d+\.\d+)/mg);
  
  print "Will attempt to apply MP3 gain of $albumgain\n";
  
  if ($albumgain > 0) {
  for (0 .. $#maxsample) {
  while ($maxsample[$_] * (2**($albumgain/4)) > 32767) {
  $clipped = 1;
  $albumgain--;
  }
  }
  }
  
  if ($clipped) {
  print "Clipping detected - reducing MP3 gain to $albumgain\n";
  }
  
  if ($albumgain != 0) {
  for $file (@quotedfiles) {
  $stdout = `mp3gain -g $albumgain -t $file`;
  }
  } else {
  print "No processing required for MP3 gain 0\n";
  }
  
--------------------


-- 
jth
------------------------------------------------------------------------
jth's Profile: http://forums.slimdevices.com/member.php?userid=48
View this thread: http://forums.slimdevices.com/showthread.php?t=18857

_______________________________________________
ripping mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/ripping

Reply via email to