Repository navigation
dbserver: fix CDJ-saved cue colour showing orange instead of green - #11
Merged
Merged
Conversation
When a cue is set on the CDJ, the deck encodes its colour in the RGB bytes (0x4f-0x51) of the 124-byte NXS2 blob with a zero palette index at 0x4e — a default hot cue arrives as idx 0 + RGB 00ff30 (green). ParseCueBlob read only the index (0), stored color_id 0, and the web UI painted palette 0x00 (Pioneer orange). Extract the colour logic into cueColorFromBlob, which recovers the colour from the RGB when the index is 0: reverse-map it to the nearest palette id (00ff30 -> 0x16, the same green the web-UI and import cues use). A non-zero index stays authoritative; all-zero RGB stays uncoloured. loadAll now re-derives the colour of every CDJ-saved cue from its raw blob on startup, so cues stored before this fix auto-correct (their JSON kept color_id 0). The served blob is re-served verbatim, so deck behaviour is untouched; this only corrects the stored/displayed colour.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Setting a hot cue on the CDJ and then viewing it in the web UI showed the wrong colour — Pioneer orange instead of the deck's green.
Root cause, from an actual saved blob: the CDJ encodes a cue's colour in the RGB bytes (0x4f-0x51) of the 124-byte NXS2 blob, with a zero palette index at 0x4e. A default hot cue arrives as index 0 + RGB 00ff30 (green).
ParseCueBlobread only the index (0), storedcolor_id 0, and the web UI painted palette 0x00 (orange). The deck itself was always fine — we re-serve the raw blob verbatim, RGB intact — so this was a stored/displayed-colour bug only.The fix:
cueColorFromBlob. When the palette index is 0, recover the colour from the RGB bytes by reverse-mapping to the nearest palette id (00ff30 maps to 0x16, the same green the web-UI and import cues use). A non-zero index stays authoritative; all-zero RGB stays uncoloured.loadAllnow re-derives the colour of every CDJ-saved cue from its raw blob on startup, so cues saved before this fix (whose JSON keptcolor_id 0) auto-correct on the next launch. Web-UI/synthesized cues have no raw blob, so they keep their stored colour.No change to what's served to the deck (the raw blob is re-served verbatim); this only corrects the colour we store and display.
Hardware testing
Checklist
go build ./...,go vet ./..., andgo test ./...passgofmt -l .is cleanGPL-3.0-or-later)