From ad4cf79cc967f973f264efe1024f5be1c9a962ec Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Feb 2022 07:46:45 +0100 Subject: [PATCH] tag: new tag "Mood" Closes https://github.com/MusicPlayerDaemon/MPD/issues/1435 --- NEWS | 2 ++ doc/protocol.rst | 1 + src/db/plugins/ProxyDatabasePlugin.cxx | 3 +++ src/tag/Id3Scan.cxx | 5 +++++ src/tag/Names.c | 1 + src/tag/Type.h | 1 + 6 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index ed0fb23b7..6f6080135 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.24 (not yet released) * player - add option "mixramp_analyzer" to scan MixRamp tags on-the-fly +* tags + - new tag "Mood" ver 0.23.6 (not yet released) * decoder diff --git a/doc/protocol.rst b/doc/protocol.rst index 24f9fb80f..4dcd021f8 100644 --- a/doc/protocol.rst +++ b/doc/protocol.rst @@ -283,6 +283,7 @@ The following tags are supported by :program:`MPD`: * **track**: the decimal track number within the album. * **name**: a name for this song. This is not the song title. The exact meaning of this tag is not well-defined. It is often used by badly configured internet radio stations with broken tags to squeeze both the artist name and the song title in one tag. * **genre**: the music genre. +* **mood**: the mood of the audio with a few keywords. * **date**: the song's release date. This is usually a 4-digit year. * **originaldate**: the song's original release date. * **composer**: the artist who composed the song. diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index df886851d..a832a7025 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -201,6 +201,9 @@ static constexpr struct { { TAG_MOVEMENT, MPD_TAG_MOVEMENT }, { TAG_MOVEMENTNUMBER, MPD_TAG_MOVEMENTNUMBER }, { TAG_LOCATION, MPD_TAG_LOCATION }, +#endif +#if LIBMPDCLIENT_CHECK_VERSION(2,21,0) + { TAG_MOOD, MPD_TAG_MOOD }, #endif { TAG_NUM_OF_ITEM_TYPES, MPD_TAG_COUNT } }; diff --git a/src/tag/Id3Scan.cxx b/src/tag/Id3Scan.cxx index 89921f908..c0d749618 100644 --- a/src/tag/Id3Scan.cxx +++ b/src/tag/Id3Scan.cxx @@ -60,6 +60,10 @@ #define ID3_FRAME_LABEL "TPUB" #endif +#ifndef ID3_FRAME_MOOD +#define ID3_FRAME_MOOD "TMOO" +#endif + gcc_pure static Id3String tag_id3_getstring(const struct id3_frame *frame, unsigned i) noexcept @@ -346,6 +350,7 @@ scan_id3_tag(const struct id3_tag *tag, TagHandler &handler) noexcept handler); tag_id3_import_text(tag, ID3_FRAME_LABEL, TAG_LABEL, handler); + tag_id3_import_text(tag, ID3_FRAME_MOOD, TAG_MOOD, handler); tag_id3_import_musicbrainz(tag, handler); tag_id3_import_ufid(tag, handler); diff --git a/src/tag/Names.c b/src/tag/Names.c index b16a42665..17a63fda4 100644 --- a/src/tag/Names.c +++ b/src/tag/Names.c @@ -30,6 +30,7 @@ const char *const tag_item_names[TAG_NUM_OF_ITEM_TYPES] = { [TAG_TRACK] = "Track", [TAG_NAME] = "Name", [TAG_GENRE] = "Genre", + [TAG_MOOD] = "Mood", [TAG_DATE] = "Date", [TAG_ORIGINAL_DATE] = "OriginalDate", [TAG_COMPOSER] = "Composer", diff --git a/src/tag/Type.h b/src/tag/Type.h index 46778d8b0..c70f3f4a2 100644 --- a/src/tag/Type.h +++ b/src/tag/Type.h @@ -45,6 +45,7 @@ enum TagType TAG_TRACK, TAG_NAME, TAG_GENRE, + TAG_MOOD, TAG_DATE, TAG_ORIGINAL_DATE, TAG_COMPOSER,