diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-10-17 12:09:44 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-10-17 12:09:44 +0000 |
| commit | a615b3fe4b4db04e9d2289f999aae53db7be8ebc (patch) | |
| tree | 50701317cff464f5cb94e139e8c15d68c87eab0f /src/plugins/General/rgscan | |
| parent | 0c8d8a0d2d328a686223138e8e8058d6c643dad3 (diff) | |
| download | qmmp-a615b3fe4b4db04e9d2289f999aae53db7be8ebc.tar.gz qmmp-a615b3fe4b4db04e9d2289f999aae53db7be8ebc.tar.bz2 qmmp-a615b3fe4b4db04e9d2289f999aae53db7be8ebc.zip | |
rgscan: added id3v2 support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3809 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/rgscan')
| -rw-r--r-- | src/plugins/General/rgscan/rgscandialog.cpp | 42 | ||||
| -rw-r--r-- | src/plugins/General/rgscan/rgscandialog.h | 5 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/plugins/General/rgscan/rgscandialog.cpp b/src/plugins/General/rgscan/rgscandialog.cpp index 1652236ac..75d9aa0e9 100644 --- a/src/plugins/General/rgscan/rgscandialog.cpp +++ b/src/plugins/General/rgscan/rgscandialog.cpp @@ -33,6 +33,8 @@ #include <taglib/oggflacfile.h> #include <taglib/vorbisfile.h> #include <taglib/wavpackfile.h> +#include <taglib/id3v2tag.h> +#include <taglib/textidentificationframe.h> #include "rgscanner.h" #include "gain_analysis.h" #include "rgscandialog.h" @@ -283,6 +285,43 @@ void RGScanDialog::writeAPETag(TagLib::APE::Tag *tag, ReplayGainInfoItem *item) } } +void RGScanDialog::writeID3v2Tag(TagLib::ID3v2::Tag *tag, ReplayGainInfoItem *item) +{ + tag->removeFrames("TXXX"); + if(m_ui.trackCheckBox->isChecked()) + { + TagLib::ID3v2::UserTextIdentificationFrame *frame = new TagLib::ID3v2::UserTextIdentificationFrame(); + TagLib::StringList fields; + fields.append("REPLAYGAIN_TRACK_GAIN"); + fields.append(gainToString(item->info[Qmmp::REPLAYGAIN_TRACK_GAIN])); + frame->setText(fields); + tag->addFrame(frame); + + fields.clear(); + frame = new TagLib::ID3v2::UserTextIdentificationFrame(); + fields.append("REPLAYGAIN_TRACK_PEAK"); + fields.append(peakToString(item->info[Qmmp::REPLAYGAIN_TRACK_PEAK])); + frame->setText(fields); + tag->addFrame(frame); + } + if(m_ui.albumCheckBox->isChecked()) + { + TagLib::ID3v2::UserTextIdentificationFrame *frame = new TagLib::ID3v2::UserTextIdentificationFrame(); + TagLib::StringList fields; + fields.append("REPLAYGAIN_ALBUM_GAIN"); + fields.append(gainToString(item->info[Qmmp::REPLAYGAIN_ALBUM_GAIN])); + frame->setText(fields); + tag->addFrame(frame); + + fields.clear(); + frame = new TagLib::ID3v2::UserTextIdentificationFrame(); + fields.append("REPLAYGAIN_ALBUM_PEAK"); + fields.append(peakToString(item->info[Qmmp::REPLAYGAIN_ALBUM_PEAK])); + frame->setText(fields); + tag->addFrame(frame); + } +} + void RGScanDialog::writeVorbisComment(TagLib::Ogg::XiphComment *tag, ReplayGainInfoItem *item) { if(m_ui.trackCheckBox->isChecked()) @@ -312,7 +351,8 @@ void RGScanDialog::on_writeButton_clicked() { TagLib::MPEG::File file(qPrintable(item->url)); writeAPETag(file.APETag(true), item); - file.save(TagLib::MPEG::File::APE, false); + writeID3v2Tag(file.ID3v2Tag(true), item); + file.save(TagLib::MPEG::File::APE | TagLib::MPEG::File::ID3v2, false); } else if(ext == "flac") //flac { diff --git a/src/plugins/General/rgscan/rgscandialog.h b/src/plugins/General/rgscan/rgscandialog.h index d196959cc..fe7132107 100644 --- a/src/plugins/General/rgscan/rgscandialog.h +++ b/src/plugins/General/rgscan/rgscandialog.h @@ -35,6 +35,10 @@ struct ReplayGainInfoItem; namespace TagLib { + namespace ID3v2 + { + class Tag; + } namespace APE { class Tag; @@ -68,6 +72,7 @@ private: TagLib::String gainToString(double value); TagLib::String peakToString(double value); void writeAPETag(TagLib::APE::Tag *tag, ReplayGainInfoItem *item); + void writeID3v2Tag(TagLib::ID3v2::Tag *tag, ReplayGainInfoItem *item); void writeVorbisComment(TagLib::Ogg::XiphComment *tag, ReplayGainInfoItem *item); Ui::RGScanDialog m_ui; QList<RGScanner *> m_scanners; |
