leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

Allow RVA2 without peak value #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am currently working on a project in which I need to write replaygain
data to MP3 files.  However, finding the peak values is impractical for
this project.  According to the specs, "Bits representing peak can be any
number between 0 and 255. 0 means that there is no peak volume field." 
However, there doesn't appear to be any way to make this happen with
mutagen. (omiting the peak value results in an exception being thrown).

Taking a quick look at the code, it looks like this might be accomplished
by changing:
    return "\x10" + pack('>H', int(round(value * 32768)))
into:
    if type(value) == type(None):
        return "\x00"
    else:
        return "\x10" + pack('>H', int(round(value * 32768)))
but I don't really know enough about it to be sure.

Original issue reported on code.google.com by rkj...@gmail.com on 3 Aug 2009 at 7:57

GoogleCodeExporter commented 9 years ago
After spending some time thinking about this, I don't want to change the current
behavior. Right now if there are no bits, it returns a peak of 0. This is not
entirely accurate, but it causes all the math in implementations of Replay Gain 
to
work out ("if scale * peak > 1 ..."). Introducing the possibility for a None 
peak
would be a major API change, and result in that math not working.

I would just pass 0 if you don't know the peak.

Original comment by joe.wreschnig@gmail.com on 10 Aug 2009 at 7:33