From 5763d042a60ba465b2f2af65a5b50032125ac790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Thu, 19 Dec 2019 14:53:57 +0100 Subject: [PATCH 1/3] Fix spelling of Bebop and update Fusion and Hardcore to match Wikipedia Source: https://en.wikipedia.org/wiki/List_of_ID3v1_Genres Similar patches will be sent to libid3tag and ffmpeg to harmonize the genre names and spellings. --- taglib/mpeg/id3v1/id3v1genres.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/taglib/mpeg/id3v1/id3v1genres.cpp b/taglib/mpeg/id3v1/id3v1genres.cpp index 1c707c30..df797658 100644 --- a/taglib/mpeg/id3v1/id3v1genres.cpp +++ b/taglib/mpeg/id3v1/id3v1genres.cpp @@ -114,8 +114,8 @@ namespace L"Folk/Rock", L"National Folk", L"Swing", - L"Fusion", - L"Bebob", + L"Fast Fusion", + L"Bebop", L"Latin", L"Revival", L"Celtic", @@ -159,7 +159,7 @@ namespace L"Goa", L"Drum & Bass", L"Club-House", - L"Hardcore", + L"Hardcore Techno", L"Terror", L"Indie", L"BritPop", From e5ad041e42caa0fc3a18d60713135cb146190202 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Thu, 24 Dec 2020 10:08:47 +0100 Subject: [PATCH 2/3] A few more corrections to genre names --- taglib/mpeg/id3v1/id3v1genres.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/taglib/mpeg/id3v1/id3v1genres.cpp b/taglib/mpeg/id3v1/id3v1genres.cpp index df797658..e2138976 100644 --- a/taglib/mpeg/id3v1/id3v1genres.cpp +++ b/taglib/mpeg/id3v1/id3v1genres.cpp @@ -59,7 +59,7 @@ namespace L"Ambient", L"Trip-Hop", L"Vocal", - L"Jazz+Funk", + L"Jazz-Funk", L"Fusion", L"Trance", L"Classical", @@ -111,7 +111,7 @@ namespace L"Rock & Roll", L"Hard Rock", L"Folk", - L"Folk/Rock", + L"Folk Rock", L"National Folk", L"Swing", L"Fast Fusion", @@ -120,7 +120,7 @@ namespace L"Revival", L"Celtic", L"Bluegrass", - L"Avantgarde", + L"Avant-garde", L"Gothic Rock", L"Progressive Rock", L"Psychedelic Rock", @@ -155,15 +155,15 @@ namespace L"Drum Solo", L"A Cappella", L"Euro-House", - L"Dance Hall", + L"Dancehall", L"Goa", L"Drum & Bass", L"Club-House", L"Hardcore Techno", L"Terror", L"Indie", - L"BritPop", - L"Negerpunk", + L"Britpop", + L"Worldbeat", L"Polsk Punk", L"Beat", L"Christian Gangsta Rap", From ae867cbd8c3bd20c6a257ba98578aabcdc2c321c Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sun, 27 Dec 2020 19:53:05 +0100 Subject: [PATCH 3/3] ID3v1: Improve compatibility by mapping renamed genre names to codes Also added a test to check if the renamed genre names are used and check if using the old names still works. --- taglib/mpeg/id3v1/id3v1genres.cpp | 21 +++++++++++++++++++++ tests/test_id3v1.cpp | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/taglib/mpeg/id3v1/id3v1genres.cpp b/taglib/mpeg/id3v1/id3v1genres.cpp index e2138976..d72a2a75 100644 --- a/taglib/mpeg/id3v1/id3v1genres.cpp +++ b/taglib/mpeg/id3v1/id3v1genres.cpp @@ -261,5 +261,26 @@ int ID3v1::genreIndex(const String &name) return i; } + // If the name was not found, try the names which have been changed + static const struct { + const wchar_t *genre; + int code; + } fixUpGenres[] = { + { L"Jazz+Funk", 29 }, + { L"Folk/Rock", 81 }, + { L"Bebob", 85 }, + { L"Avantgarde", 90 }, + { L"Dance Hall", 125 }, + { L"Hardcore", 129 }, + { L"BritPop", 132 }, + { L"Negerpunk", 133 } + }; + static const int fixUpGenresSize = + sizeof(fixUpGenres) / sizeof(fixUpGenres[0]); + for(int i = 0; i < fixUpGenresSize; ++i) { + if(name == fixUpGenres[i].genre) + return fixUpGenres[i].code; + } + return 255; } diff --git a/tests/test_id3v1.cpp b/tests/test_id3v1.cpp index 3358aead..c50c3428 100644 --- a/tests/test_id3v1.cpp +++ b/tests/test_id3v1.cpp @@ -40,6 +40,7 @@ class TestID3v1 : public CppUnit::TestFixture CPPUNIT_TEST_SUITE(TestID3v1); CPPUNIT_TEST(testStripWhiteSpace); CPPUNIT_TEST(testGenres); + CPPUNIT_TEST(testRenamedGenres); CPPUNIT_TEST_SUITE_END(); public: @@ -68,6 +69,18 @@ public: CPPUNIT_ASSERT_EQUAL(100, ID3v1::genreIndex("Humour")); } + void testRenamedGenres() + { + CPPUNIT_ASSERT_EQUAL(String("Bebop"), ID3v1::genre(85)); + CPPUNIT_ASSERT_EQUAL(85, ID3v1::genreIndex("Bebop")); + CPPUNIT_ASSERT_EQUAL(85, ID3v1::genreIndex("Bebob")); + + ID3v1::Tag tag; + tag.setGenre("Hardcore"); + CPPUNIT_ASSERT_EQUAL(String("Hardcore Techno"), tag.genre()); + CPPUNIT_ASSERT_EQUAL(129U, tag.genreNumber()); + } + }; CPPUNIT_TEST_SUITE_REGISTRATION(TestID3v1);