[PATCH] ReplayGain tags
Alex Merry
kde at randomguy3.me.uk
Sun Jan 11 01:08:20 CET 2009
Attached is a patch that scans for the replaygain tags in Ogg Vorbis and FLAC
files, and puts them in the database. That's all it does at the moment (the
database values are not accessible, for example) because I wanted some
feedback before I continue on whether this is the right thing to do.
What it does:
* adds the xesam albumGain and trackGain fields to Meta::Fields (these are
in the xesam metadata spec).
* adds two new fields to the tracks table in the database: trackgain and
albumgain. Also creates a working update path for old database versions.
* collectionscanner looks for REPLAYGAIN_ALBUM_GAIN and REPLAYGAIN_TRACK_GAIN
in Vorbis and FLAC files. Note that MP3 and MP4 files have a global gain
field that is interpreted by the MP3 or MP4 decoder, and so don't store
this stuff in tags (they store the undo data in the tags instead, which we
don't care about).
* ScanManager and ScanResultProcessor deal with the trackgain and albumgain
values returned by the collectionscanner.
* XesamCollectionBuilder also asks for xesam:albumGain and xesam:trackGain
and puts those values in the database if they exist.
I incremented the DB_VERSION to 2 and made DatabaseUpdater::update() modify
the tracks table if the version of the existing database was 1. Also, it does
a full collection rescan (since an incremental scan only checks for changed
files - there is no "look for new metadata in all the old files without
clearing out the database" mode for collectionscanner).
The values are successfully stored in the database.
Known issue: the full rescan makes the playlist lose all metadata apart from
the track titles. I reckon this could be solved with an "update metadata"
option to collectionscanner.
So: is this a sensible path to go down for implementing ReplayGain support in
Amarok? I ask now in case the answer is "God, no, don't touch the database!"
Sorry for the long email, but hopefully all that spiel will help make the
patch easier to read / make it so you don't have to read the patch at all.
Alex
PS: I haven't fully figured out where the actual sound manipulation should go.
Wherever it goes, it really needs access to the setVolumeDecibel() method of
the Phonon::AudioOutput in EngineController. But it also needs access to the
replay gain metadata, which is the point of this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: amarok-replaygain-scanning.diff
Type: text/x-patch
Size: 14164 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/amarok-devel/attachments/20090111/749ca809/attachment.diff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/amarok-devel/attachments/20090111/749ca809/attachment.sig
More information about the Amarok-devel
mailing list