Copy replaygain information?

The place for "I can't figure out how to..." questions.
Post Reply
nitro322
User
Posts: 10
Joined: Wed Jul 19, 2006 3:48 am

Copy replaygain information?

Post by nitro322 » Mon Aug 21, 2006 6:17 am

How do I write ReplayGain data to a file? I see in structure.txt that replaygain information is stored in the 'replay_gain' array, and in fact can output it like this:

Code: Select all

$tags = $getID3->analyze($file);
print_r($tags['replay_gain']);

//output follows
Array
(
    [track] => Array
        (
            [peak] => 0.93527222
            [adjustment] => -2.79
            [volume] => 91.79
            [max_noclip_gain] => 0.581239302611
        )

    [album] => Array
        (
            [peak] => 0.99996948
            [adjustment] => -1.85
            [volume] => 90.85
            [max_noclip_gain] => 0.000265097397161
        )

    [reference_volume] => 89
)
So, let's say I transcode this file to an MP3 and want to maintain the replaygain data. How do I apply this information to the MP3?

Thanks.

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Mon Aug 21, 2006 7:50 am

I believe there are four different ways with MP3:

1. Adjust the gain in the file to either track or album.

2. Adjust values in the LAMEtag (if present).

3. RGAD frame in ID3v2

4. APEtag, set the following fields
replaygain_track_gain
replaygain_track_gain_peak
replaygain_album_gain
replaygain_album_gain_peak


The old version of mp3gain uses method 1. getID3() cannot detect replaygain in such files.

The new version of mp3gain uses method 2 or 3 (not sure which).

foobar2000 uses method 4 when writing APEtags only. Not sure if it does method 2 or 3 sometimes.


Method 1 and 2 cannot be done with getID3().
Method 3 might be doable with getID3().
Method 4 is doable with getID3().

nitro322
User
Posts: 10
Joined: Wed Jul 19, 2006 3:48 am

Post by nitro322 » Fri Aug 25, 2006 4:41 am

Thanks, Allan! I was able to get option 4 working, as you suggested. Everything's working great now. :)

Post Reply