-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into coverimagehash
- Loading branch information
Showing
16 changed files
with
295 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include "track/serato/tags.h" | ||
|
||
namespace { | ||
|
||
class SeratoTagsTest : public testing::Test { | ||
protected: | ||
void trackColorRoundtrip(mixxx::RgbColor storedColor, mixxx::RgbColor::optional_t displayedColor) { | ||
mixxx::RgbColor::optional_t actualDisplayedColor = mixxx::SeratoTags::storedToDisplayedTrackColor(storedColor); | ||
EXPECT_EQ(displayedColor, actualDisplayedColor); | ||
|
||
mixxx::RgbColor actualStoredColor = mixxx::SeratoTags::displayedToStoredTrackColor(actualDisplayedColor); | ||
EXPECT_EQ(actualStoredColor, storedColor); | ||
} | ||
}; | ||
|
||
TEST_F(SeratoTagsTest, ParseTrackColor) { | ||
trackColorRoundtrip(mixxx::RgbColor(0xFF99FF), mixxx::RgbColor::optional(0x993399)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFF99DD), mixxx::RgbColor::optional(0x993377)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFF99BB), mixxx::RgbColor::optional(0x993355)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFF9999), mixxx::RgbColor::optional(0x993333)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFFBB99), mixxx::RgbColor::optional(0x995533)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFFDD99), mixxx::RgbColor::optional(0x997733)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFFFF99), mixxx::RgbColor::optional(0x999933)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xDDFF99), mixxx::RgbColor::optional(0x779933)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xBBFF99), mixxx::RgbColor::optional(0x559933)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99FF99), mixxx::RgbColor::optional(0x339933)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99FFBB), mixxx::RgbColor::optional(0x339955)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99FFDD), mixxx::RgbColor::optional(0x339977)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99FFFF), mixxx::RgbColor::optional(0x339999)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99DDFF), mixxx::RgbColor::optional(0x337799)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x99BBFF), mixxx::RgbColor::optional(0x335599)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x9999FF), mixxx::RgbColor::optional(0x333399)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xBB99FF), mixxx::RgbColor::optional(0x553399)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xDD99FF), mixxx::RgbColor::optional(0x773399)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x000000), mixxx::RgbColor::optional(0x333333)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xBBBBBB), mixxx::RgbColor::optional(0x555555)); | ||
trackColorRoundtrip(mixxx::RgbColor(0x999999), mixxx::RgbColor::optional(0x090909)); | ||
trackColorRoundtrip(mixxx::RgbColor(0xFFFFFF), std::nullopt); | ||
} | ||
|
||
} // namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include "track/serato/tags.h" | ||
|
||
namespace mixxx { | ||
|
||
RgbColor::optional_t SeratoTags::storedToDisplayedTrackColor(RgbColor color) { | ||
// Serato stores Track colors differently from how they are displayed in | ||
// the library column. Instead of the color from the library view, the | ||
// value from the color picker is stored instead (which is different). | ||
// To make sure that the track looks the same in both Mixxx' and Serato's | ||
// libraries, we need to convert between the two values. | ||
// | ||
// See this for details: | ||
// https://github.com/Holzhaus/serato-tags/blob/master/docs/colors.md#track-colors | ||
|
||
if (color == 0xFFFFFF) { | ||
return RgbColor::nullopt(); | ||
} | ||
|
||
if (color == 0x999999) { | ||
return RgbColor::optional(0x090909); | ||
} | ||
|
||
if (color == 0x000000) { | ||
return RgbColor::optional(0x333333); | ||
} | ||
|
||
RgbColor::code_t colorCode = color; | ||
colorCode = (colorCode < 0x666666) ? colorCode + 0x99999A : colorCode - 0x666666; | ||
return RgbColor::optional(colorCode); | ||
} | ||
|
||
RgbColor SeratoTags::displayedToStoredTrackColor(RgbColor::optional_t color) { | ||
if (!color) { | ||
return RgbColor(0xFFFFFF); | ||
} | ||
|
||
RgbColor::code_t colorCode = *color; | ||
|
||
if (colorCode == 0x090909) { | ||
return RgbColor(0x999999); | ||
} | ||
|
||
if (colorCode == 0x333333) { | ||
return RgbColor(0x000000); | ||
} | ||
|
||
// Special case: 0x999999 and 0x99999a are not representable as Serato | ||
// track color We'll just modify them a little, so that the look the | ||
// same in Serato. | ||
if (colorCode == 0x999999) { | ||
return RgbColor(0x999998); | ||
} | ||
|
||
if (colorCode == 0x99999a) { | ||
return RgbColor(0x99999b); | ||
} | ||
|
||
colorCode = (colorCode < 0x99999A) ? colorCode + 0x666666 : colorCode - 0x99999A; | ||
return RgbColor(colorCode); | ||
} | ||
|
||
RgbColor::optional_t SeratoTags::getTrackColor() const { | ||
RgbColor::optional_t color = m_seratoMarkers.getTrackColor(); | ||
|
||
if (!color) { | ||
// Markers_ is empty, but we may have a color in Markers2 | ||
color = m_seratoMarkers2.getTrackColor(); | ||
} | ||
|
||
if (color) { | ||
color = SeratoTags::storedToDisplayedTrackColor(*color); | ||
} | ||
|
||
return color; | ||
} | ||
|
||
bool SeratoTags::isBpmLocked() const { | ||
return m_seratoMarkers2.isBpmLocked(); | ||
} | ||
|
||
} // namespace mixxx |
Oops, something went wrong.