From 6afcd0f8d33bcc6a1ebaebff4806883f8895df7f Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 1 Jan 2019 23:38:39 +0100 Subject: [PATCH] Support album artist and fix/improve grouping --- CMakeLists.txt | 4 ++-- id3/id3v2frameids.cpp | 4 ++++ id3/id3v2frameids.h | 6 ++++-- id3/id3v2tag.cpp | 11 +++++++++-- mp4/mp4tag.cpp | 4 ++++ tag.h | 5 ++++- vorbis/vorbiscomment.cpp | 33 +++++++++++++++++++++++++++------ vorbis/vorbiscommentids.h | 8 ++++++++ 8 files changed, 62 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31bd10f..d77ac23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,8 +179,8 @@ set(META_APP_AUTHOR "Martchus") set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") set(META_APP_DESCRIPTION "C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags") set(META_VERSION_MAJOR 8) -set(META_VERSION_MINOR 0) -set(META_VERSION_PATCH 2) +set(META_VERSION_MINOR 1) +set(META_VERSION_PATCH 0) set(META_PUBLIC_SHARED_LIB_DEPENDS c++utilities) set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static) set(META_REQUIRED_CPP_UNIT_VERSION 1.14.0) diff --git a/id3/id3v2frameids.cpp b/id3/id3v2frameids.cpp index 0c87396..823dd0a 100644 --- a/id3/id3v2frameids.cpp +++ b/id3/id3v2frameids.cpp @@ -59,6 +59,8 @@ uint32 convertToShortId(uint32 id) return sUnsynchronizedLyrics; case lGrouping: return sGrouping; + case lContentGroupDescription: + return sContentGroupDescription; case lRecordLabel: return sRecordLabel; case lUserDefinedText: @@ -111,6 +113,8 @@ uint32 convertToLongId(uint32 id) return lUnsynchronizedLyrics; case sGrouping: return lGrouping; + case sContentGroupDescription: + return lContentGroupDescription; case sRecordLabel: return lRecordLabel; case sUserDefinedText: diff --git a/id3/id3v2frameids.h b/id3/id3v2frameids.h index 9c5dd50..a9360af 100644 --- a/id3/id3v2frameids.h +++ b/id3/id3v2frameids.h @@ -27,7 +27,8 @@ enum KnownValue : uint32 { lEncoderSettings = 0x54535345, lUnsynchronizedLyrics = 0x55534c54, lSynchronizedLyrics = 0x53594C54, - lGrouping = 0x54504532, + lGrouping = 0x54504532, // FIXME: rename to lAlbumArtist in v9 + lContentGroupDescription = 0x54495431, lRecordLabel = 0x54505542, lUniqueFileId = 0x55464944, lComposer = 0x54434f4d, @@ -52,7 +53,8 @@ enum KnownValue : uint32 { sEncoderSettings = 0x545353, sUnsynchronizedLyrics = 0x554C54, sSynchronizedLyrics = 0x534C54, - sGrouping = 0x545032, + sGrouping = 0x545032, // FIXME: rename to sAlbumArtist in v9 + sContentGroupDescription = 0x545431, sRecordLabel = 0x545042, sUniqueFileId = 0x554649, sComposer = 0x54434d, diff --git a/id3/id3v2tag.cpp b/id3/id3v2tag.cpp index 12418e4..46b94e6 100644 --- a/id3/id3v2tag.cpp +++ b/id3/id3v2tag.cpp @@ -44,6 +44,7 @@ bool Id3v2Tag::supportsMultipleValues(KnownField field) const case KnownField::Grouping: case KnownField::RecordLabel: case KnownField::Composer: + case KnownField::AlbumArtist: return m_majorVersion > 3; case KnownField::Rating: case KnownField::Comment: @@ -166,13 +167,15 @@ Id3v2Tag::IdentifierType Id3v2Tag::internallyGetFieldId(KnownField field) const case KnownField::SynchronizedLyrics: return lSynchronizedLyrics; case KnownField::Grouping: - return lGrouping; + return lContentGroupDescription; case KnownField::RecordLabel: return lRecordLabel; case KnownField::Composer: return lComposer; case KnownField::Rating: return lRating; + case KnownField::AlbumArtist: + return lGrouping; default:; } } else { @@ -214,13 +217,15 @@ Id3v2Tag::IdentifierType Id3v2Tag::internallyGetFieldId(KnownField field) const case KnownField::SynchronizedLyrics: return sSynchronizedLyrics; case KnownField::Grouping: - return sGrouping; + return sContentGroupDescription; case KnownField::RecordLabel: return sRecordLabel; case KnownField::Composer: return sComposer; case KnownField::Rating: return sRating; + case KnownField::AlbumArtist: + return sGrouping; default:; } } @@ -268,6 +273,8 @@ KnownField Id3v2Tag::internallyGetKnownField(const IdentifierType &id) const case lSynchronizedLyrics: return KnownField::SynchronizedLyrics; case lGrouping: + return KnownField::AlbumArtist; + case lContentGroupDescription: return KnownField::Grouping; case lRecordLabel: return KnownField::RecordLabel; diff --git a/mp4/mp4tag.cpp b/mp4/mp4tag.cpp index f7b6658..9322b37 100644 --- a/mp4/mp4tag.cpp +++ b/mp4/mp4tag.cpp @@ -159,6 +159,8 @@ Mp4Tag::IdentifierType Mp4Tag::internallyGetFieldId(KnownField field) const return Performers; case KnownField::Lyricist: return Lyricist; + case KnownField::AlbumArtist: + return AlbumArtist; default: return 0; } @@ -207,6 +209,8 @@ KnownField Mp4Tag::internallyGetKnownField(const IdentifierType &id) const return KnownField::Performers; case Lyricist: return KnownField::Lyricist; + case AlbumArtist: + return KnownField::AlbumArtist; default: return KnownField::Invalid; } diff --git a/tag.h b/tag.h index 4e9e668..d9df465 100644 --- a/tag.h +++ b/tag.h @@ -35,6 +35,8 @@ enum class TagType : unsigned int { * * Not all fields are supported by all tag types (see Tag::supportsField()). * + * Mapping proposed by HAK: https://wiki.hydrogenaud.io/index.php?title=Tag_Mapping + * * \sa Tag::type() */ enum class KnownField : unsigned int { @@ -66,7 +68,8 @@ enum class KnownField : unsigned int { Composer, /**< composer */ Rating, /**< rating */ Description, /**< description */ - Vendor /**< vendor */ + Vendor, /**< vendor */ + AlbumArtist, /**< album artist */ }; /*! diff --git a/vorbis/vorbiscomment.cpp b/vorbis/vorbiscomment.cpp index c8eb048..f58d53c 100644 --- a/vorbis/vorbiscomment.cpp +++ b/vorbis/vorbiscomment.cpp @@ -77,6 +77,8 @@ VorbisComment::IdentifierType VorbisComment::internallyGetFieldId(KnownField fie return encoderSettings(); case KnownField::Description: return description(); + case KnownField::Grouping: + return grouping(); case KnownField::RecordLabel: return label(); case KnownField::Performers: @@ -85,6 +87,8 @@ VorbisComment::IdentifierType VorbisComment::internallyGetFieldId(KnownField fie return language(); case KnownField::Lyricist: return lyricist(); + case KnownField::AlbumArtist: + return albumArtist(); default: return string(); } @@ -93,12 +97,29 @@ VorbisComment::IdentifierType VorbisComment::internallyGetFieldId(KnownField fie KnownField VorbisComment::internallyGetKnownField(const IdentifierType &id) const { using namespace VorbisCommentIds; - static const map fieldMap({ { album(), KnownField::Album }, { artist(), KnownField::Artist }, - { comment(), KnownField::Comment }, { cover(), KnownField::Cover }, { date(), KnownField::Year }, { title(), KnownField::Title }, - { genre(), KnownField::Genre }, { trackNumber(), KnownField::TrackPosition }, { diskNumber(), KnownField::DiskPosition }, - { partNumber(), KnownField::PartNumber }, { composer(), KnownField::Composer }, { encoder(), KnownField::Encoder }, - { encoderSettings(), KnownField::EncoderSettings }, { description(), KnownField::Description }, { label(), KnownField::RecordLabel }, - { performer(), KnownField::Performers }, { lyricist(), KnownField::Lyricist } }); + // clang-format off + static const map fieldMap({ + { album(), KnownField::Album }, + { artist(), KnownField::Artist }, + { comment(), KnownField::Comment }, + { cover(), KnownField::Cover }, + { date(), KnownField::Year }, + { title(), KnownField::Title }, + { genre(), KnownField::Genre }, + { trackNumber(), KnownField::TrackPosition }, + { diskNumber(), KnownField::DiskPosition }, + { partNumber(), KnownField::PartNumber }, + { composer(), KnownField::Composer }, + { encoder(), KnownField::Encoder }, + { encoderSettings(), KnownField::EncoderSettings }, + { description(), KnownField::Description }, + { grouping(), KnownField::Grouping }, + { label(), KnownField::RecordLabel }, + { performer(), KnownField::Performers }, + { lyricist(), KnownField::Lyricist }, + { albumArtist(), KnownField::AlbumArtist }, + }); + // clang-format on const auto knownField(fieldMap.find(id)); return knownField != fieldMap.cend() ? knownField->second : KnownField::Invalid; } diff --git a/vorbis/vorbiscommentids.h b/vorbis/vorbiscommentids.h index 46e8883..48022e6 100644 --- a/vorbis/vorbiscommentids.h +++ b/vorbis/vorbiscommentids.h @@ -38,6 +38,14 @@ constexpr TAG_PARSER_EXPORT const char *artist() { return "ARTIST"; } +constexpr TAG_PARSER_EXPORT const char *albumArtist() +{ + return "ALBUMARTIST"; +} +constexpr TAG_PARSER_EXPORT const char *grouping() +{ + return "GROUPING"; +} constexpr TAG_PARSER_EXPORT const char *album() { return "ALBUM";