I'm successfully using gnupod on my iPod video 30GB. Thanks to everyone who contributed to this great tool!

I have all my mp3s tagged for ReplayGain volume leveling using mp3gain. This tool adds ReplayGain information using APE tags. Making gnupod read these tags and apply them as SoundCheck values was surprisingly easy. Boy, I love open source software. :-)

There might be a side effect if you have APE tags that also contain (wrong) title and artist information. I don't have such files to test with, but implementing a --disable-ape switch might be a good idea. Let me know if you need me to provide a patch for that as well.

This patch is against the current CVS version. It will prefer ReplayGain APE/id3v2 tags over iTunNORM id3v2 comments. The ReplayGain algorithm is far superior over the peak based SoundCheck algorithm iTunes implements, so it wouldn't make sense the other way around.

Regards,

Richard
*** FileMagic.pm.orig   2009-04-17 22:46:54.000000000 +0200
--- FileMagic.pm        2009-04-17 22:51:25.000000000 +0200
***************
*** 483,489 ****
        $rh{fdesc}    = "MPEG ${$h}{VERSION} layer ${$h}{LAYER} file";
        
        $h  = MP3::Info::get_mp3tag($file,1)    unless $flags->{'noIDv1'};  
#Get the IDv1 tag
!       $hs = MP3::Info::get_mp3tag($file,2,2)  unless $flags->{'noIDv2'};  
#Get the IDv2 tag
        
        my $nonitunescomment = undef;
        #The IDv2 Hashref may return arrays.. kill them :)
--- 483,489 ----
        $rh{fdesc}    = "MPEG ${$h}{VERSION} layer ${$h}{LAYER} file";
        
        $h  = MP3::Info::get_mp3tag($file,1)    unless $flags->{'noIDv1'};  
#Get the IDv1 tag
!       $hs = MP3::Info::get_mp3tag($file,2,2,1)  unless $flags->{'noIDv2'};  
#Get the APE + IDv2 tag
        
        my $nonitunescomment = undef;
        #The IDv2 Hashref may return arrays.. kill them :)
***************
*** 519,525 ****
        $rh{desc}       = __merge_strings({joinby => " ", wspace => "norm", 
case => "ignore"},($hs->{USLT} || $hs->{ULT}),($nonitunescomment || 
$h->{COMMENT}));
        $rh{composer}   = ($hs->{TCOM} || $hs->{TCM} || "");
        $rh{playcount}  = int($hs->{PCNT} || $hs->{CNT}) || 0;
!       $rh{soundcheck} = _parse_iTunNORM($hs->{COMM} || $hs->{COM} || 
$h->{COMMENT});
        $rh{mediatype}  = MEDIATYPE_AUDIO;
  
        # Handle volume adjustment information
--- 519,529 ----
        $rh{desc}       = __merge_strings({joinby => " ", wspace => "norm", 
case => "ignore"},($hs->{USLT} || $hs->{ULT}),($nonitunescomment || 
$h->{COMMENT}));
        $rh{composer}   = ($hs->{TCOM} || $hs->{TCM} || "");
        $rh{playcount}  = int($hs->{PCNT} || $hs->{CNT}) || 0;
!       if($hs->{REPLAYGAIN_TRACK_GAIN} ne "") {
!               $rh{soundcheck} = 
convertReplayGainToSoundCheck($hs->{REPLAYGAIN_TRACK_GAIN});
!       } else {
!               $rh{soundcheck} = _parse_iTunNORM($hs->{COMM} || $hs->{COM} || 
$h->{COMMENT});
!       }
        $rh{mediatype}  = MEDIATYPE_AUDIO;
  
        # Handle volume adjustment information
***************
*** 789,794 ****
--- 793,821 ----
  
  =cut
  
+ #########################################################
+ # Convert ReplayGain to SoundCheck
+ sub convertReplayGainToSoundCheck {
+       my ($gain) = @_;
+       if ( $gain =~ /(.*)\s+dB$/ ) {
+               $gain = $1;
+       }
+       my $result = round((10 ** (-$gain / 10)) * 1000);
+       
+       if ($result > 65534) {
+               $result = 65534;
+       }
+       
+       return oct(sprintf("0x%08X",$result));
+ }
+ 
+ #########################################################
+ # Round to next integer
+ sub round {
+       my $number = shift;
+       return int($number + .5 * ($number <=> 0));
+ }
+ 
  1;
  
  
_______________________________________________
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod

Reply via email to