Calling external command after save action


#1

Hi!

Is it possible to make Picard automatically call an external command after saving files? I would be very happy that “collectiongain” is executed at that time on my collection (see https://github.com/cacack/rgain), possibly via a plugin? Can the plugin system allow to hook after the save file action?

Thanks!


#2

Not sure about the general case, but for this specific case you should be able to use the Replaygain plug-in.


#3

Actually rgain does a much better job than Picard ReplayGain plugin (which use the unmaintained mp3gain tool under the hood)…


#4

If you say so. Regardless, the general case is interesting, but I have no idea. Maybe @Sophist would know?


#5

I took a quick look at the ReplayGain plugin code. The way it works is to add ReplayGain to Album and File context (right-click) menus so that you can manually run the plugin on a file. For obvious reasons, you would not want to run replaygain on files automatically (at load or save) unless you could reliably determine that the replay gain has not already been calculated. Similarly you would not want to run replaygain on every file on save, unless it checked to see if it was needed.

Picard does not currently support replaygain tags (e.g. ID3v23 RVAD, id3v24 RVA2), and I don’t think it is that easy to patch Picard from a plugin to add this support - adding this support to Picard is on my To-Do list when I get the time (which is not soon - as I have other open-source developments I am working on at present).

However, once Picard supports the tags, it should be possible to write a plugin which checks the tags on file loading and calculates the replaygain for those files which don’t have the tags.

It should be noted that (according to HydrogenAudio and Wikipedia) mp3gain does not set the RVAD/RVA2 tags, but instead adjusts the volume of each MP3 frame. It apparently stores the original information in a tag so it can be reversed, but I haven’t researched what this tag is and whether this could be used to determine whether you need to run replaygain. I haven’t looked into what the replaygain utilities for other formats do.

It should also be noted that rgain does not support id3vRVAD, only id3v24 RVA2. Again, it should be possible to hack the rgain code to include it in the plugin rather than run it as an external command.