Skip to content

Allow setting ReplayGain values for MPC (Musepack) #923

Open

Description

@Moonbase59

While trying to add MusePack as a taggable format for loudgain, I just discovered that

TagLib::MPC::Properties::albumGain
TagLib::MPC::Properties::albumPeak
TagLib::MPC::Properties::trackGain
TagLib::MPC::Properties::trackPeak

are const in TagLib, so can’t be overwritten.

It’s of course mandatory for a replaygain tool to be able to write the calculated values, even in the header area. It seems that others (like Amarok) also see this problem.

I wouldn’t want to introduce yet another dependency in loudgain, so I kindly ask if this restriction could please be removed in TagLib.

Activity

  1. scotchi commented on Sep 12, 2019

    @scotchi
    Member

    This does bring up an interesting question --

    At the moment those values are part of the AudioProperties, not part of the Tag. For all file types in TagLib, AudioProperties are read only. In this particular case, MPC does use an odd mix metadata and format data in its headers that I'm not aware of existing in any other format.

    At any rate, the issue isn't simply the structures being const -- it's that there's no code for writing those properties at all; they're just read-only internally, so making them read-write would require both code for writing those files back to the original files, and updates to the MPC::File API.

  2. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    Thanks for caring!

    Yes, I agree that’s an odd situation, Musepack being the only format that holds ReplayGain data in the header. Somehow good and bad. Still I would love to see this possible, if anyhow doable. I also found an old comment from the Amarok developers somewhere, complaining that "TagLib doesn’t let us at the values". They worked around it by writing APEv2 tags, apparently, but that’s non-standard, since almost all players I could find only read the ReplayGain header data.

    Writing a ReplayGain tool, it’s of course mandatory to be able to write the correct values, and I quite like TagLib for its clarity and structuredness, so it would be just great to have it (and maybe even make others happy).

    In general, I think it might be good if TagLib could allow (selected?) fields in headers been rewritten, thinking of the Opus output_gain field … (see #916).

  3. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    Reading the SV7 spec, I just found that apparently the "gain" values are signed int whereas the "peak" values are not.

    In taglib/mpc/mpcproperties.cpp, you have unsigned for all values:

      unsigned int trackGain;
      unsigned int trackPeak;
      unsigned int albumGain;
      unsigned int albumPeak;

    For the SV8 spec, I’m a little unsure because they talk of negative and positive numbers, apparently Q8.8 encoded.

  4. scotchi commented on Sep 12, 2019

    @scotchi
    Member

    Thanks. Also problematic was lower in the file where toShort instead of toUShort was used. Unfortunately there are still no tests for decoding SV7, so I'll see if some can be created before the upcoming release.

  5. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    Let me know if you need a few test files, I have some here for my loudgain testing.

  6. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    N.B.: Might be nice to also consider the "ReplayGain version" field for writing, I might need to write a "2" there … It’s 8 bit, but the spec is a little unclear if signed or not.

  7. scotchi commented on Sep 12, 2019

    @scotchi
    Member

    If you have some with a SV7 headers, that'd be great, particularly if they have a negative gain. You can send them to [email protected].

  8. Moonbase59 commented on Sep 12, 2019

    @Moonbase59
    Author

    With pleasure, I’ll just go and zip ’em up. Will 42 MB fit into your email? (They’re real files, not just shortened tests.)

    EDIT: Attachment too large for my own mail server, I sent you a mail with a download link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions