diff --git a/CHANGELOG b/CHANGELOG index e697585bbb7..5f77332d198 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,8 @@ * Fix missing manual in deb package lp:1889776 * Fix caching of duplicate tracks that reference the same file #3027 * Fix loss of precision when dealing with floating-point sample positions while setting loop out position and seeking using vinyl control #3126 #3127 -* prevent moving a loop beyond track end #3117 https://bugs.launchpad.net/mixxx/+bug/1799574 +* Prevent moving a loop beyond track end #3117 https://bugs.launchpad.net/mixxx/+bug/1799574 +* Use 6 instead of only 4 compatible musical keys (major/minor) #3205 ==== 2.2.4 2020-05-10 ==== diff --git a/src/test/keyutilstest.cpp b/src/test/keyutilstest.cpp index 612ea88b0dc..d8fb1481073 100644 --- a/src/test/keyutilstest.cpp +++ b/src/test/keyutilstest.cpp @@ -1,13 +1,12 @@ -#include #include +#include + #include -#include "track/keyutils.h" #include "proto/keys.pb.h" +#include "track/keyutils.h" -using ::testing::ElementsAre; - -namespace { +using ::testing::UnorderedElementsAre; class KeyUtilsTest : public testing::Test { }; @@ -206,8 +205,9 @@ TEST_F(KeyUtilsTest, ShortestStepsToKey) { } TEST_F(KeyUtilsTest, GetCompatibleKeys) { - // The relative major, the perfect 4th and the perfect 5th are all - // compatible. This is easily checked with the Circle of Fifths. + // The relative major/minor, the perfect 4th major/minor and the + // perfect 5th major/minor are all compatible. This is easily + // checked with the Circle of Fifths. // Test keys on the boundary between 1 and 12 to check that wrap-around // works. @@ -215,21 +215,21 @@ TEST_F(KeyUtilsTest, GetCompatibleKeys) { mixxx::track::io::key::A_MINOR; QList compatible = KeyUtils::getCompatibleKeys(key); - qSort(compatible); - EXPECT_THAT(compatible, ElementsAre( - mixxx::track::io::key::C_MAJOR, - mixxx::track::io::key::D_MINOR, - mixxx::track::io::key::E_MINOR, - mixxx::track::io::key::A_MINOR)); + EXPECT_THAT(compatible, + UnorderedElementsAre(mixxx::track::io::key::C_MAJOR, + mixxx::track::io::key::F_MAJOR, + mixxx::track::io::key::G_MAJOR, + mixxx::track::io::key::D_MINOR, + mixxx::track::io::key::E_MINOR, + mixxx::track::io::key::A_MINOR)); key = mixxx::track::io::key::F_MAJOR; compatible = KeyUtils::getCompatibleKeys(key); - qSort(compatible); - EXPECT_THAT(compatible, ElementsAre( - mixxx::track::io::key::C_MAJOR, - mixxx::track::io::key::F_MAJOR, - mixxx::track::io::key::B_FLAT_MAJOR, - mixxx::track::io::key::D_MINOR)); + EXPECT_THAT(compatible, + UnorderedElementsAre(mixxx::track::io::key::C_MAJOR, + mixxx::track::io::key::F_MAJOR, + mixxx::track::io::key::B_FLAT_MAJOR, + mixxx::track::io::key::D_MINOR, + mixxx::track::io::key::A_MINOR, + mixxx::track::io::key::G_MINOR)); } - -} // namespace diff --git a/src/test/rescalertest.cpp b/src/test/rescalertest.cpp index a5ab8afe1c5..f6bf014edf4 100644 --- a/src/test/rescalertest.cpp +++ b/src/test/rescalertest.cpp @@ -1,15 +1,9 @@ #include -#include #include #include "util/math.h" #include "util/rescaler.h" - -using ::testing::ElementsAre; - -namespace { - class RescalerUtilsTest : public testing::Test { }; @@ -62,5 +56,3 @@ TEST_F(RescalerUtilsTest, Test) { result = RescalerUtils::oneByXToLinear(result, 1000, 0, 100); EXPECT_TRUE(fabs(result - 50) < 0.0000000001); } - -} // namespace diff --git a/src/track/keyutils.cpp b/src/track/keyutils.cpp index 69ca80fb0b5..9ea05ef0634 100644 --- a/src/track/keyutils.cpp +++ b/src/track/keyutils.cpp @@ -515,15 +515,15 @@ QList KeyUtils::getCompatibleKeys( return compatible; } + int openKeyNumber = KeyUtils::keyToOpenKeyNumber(key); // We know the key is in the set of valid values. Save whether or not the // value is minor. bool major = keyIsMajor(key); - int openKeyNumber = KeyUtils::keyToOpenKeyNumber(key); // The compatible keys of particular key are: // * The relative major/minor key. - // * The perfect 4th (sub-dominant) key. - // * The perfect 5th (dominant) key. + // * The perfect 4th (sub-dominant) major/minor key. + // * The perfect 5th (dominant) major/minor key. // // The Circle of Fifths is a handy tool that encodes this compatibility. // Keys on the same radial of the circle are compatible and adjacent keys on @@ -535,14 +535,22 @@ QList KeyUtils::getCompatibleKeys( // The key is compatible with tracks in the same key. compatible << key; + auto relativeKey = openKeyNumberToKey(openKeyNumber, !major); + int relativeOpenKeyNumber = KeyUtils::keyToOpenKeyNumber(relativeKey); + // The relative major/minor key is compatible. - compatible << openKeyNumberToKey(openKeyNumber, !major); + compatible << relativeKey; - // The perfect 4th and perfect 5th are compatible. + // The perfect 4th and perfect 5th of BOTH major and minor key are compatible + // (as explained by Phil Morse: https://youtu.be/9eECvYYAwbg?t=2370) compatible << openKeyNumberToKey( openKeyNumber == 12 ? 1 : openKeyNumber + 1, major); + compatible << openKeyNumberToKey( + relativeOpenKeyNumber == 12 ? 1 : relativeOpenKeyNumber + 1, !major); compatible << openKeyNumberToKey( openKeyNumber == 1 ? 12 : openKeyNumber - 1, major); + compatible << openKeyNumberToKey( + relativeOpenKeyNumber == 1 ? 12 : relativeOpenKeyNumber - 1, !major); return compatible; }