Fixed issues with cross-platform memory-cue naming and coloring

This commit is contained in:
patben8 committed 2026-10-16 15:04:43 +02:00
1 parent 19a604f730
commit 1f2ca18e8a
5 files changed
+26 -8

No files matched your search

@@ -367,12 +367,13 @@ class OneLibraryExporter:
if is_memory: if is_memory:
# rekordbox keeps 10 (earliest first; the rest are dropped, per # rekordbox keeps 10 (earliest first; the rest are dropped, per
# the lossiness rule). A memory cue's colour is PCP2 byte 28 from # the lossiness rule). A memory cue's colour is PCP2 byte 28 from
# its own 8-colour palette; the hot-cue code + RGB stay zero. # its own 8-colour palette — what Konduktor SHOWS (stored, else
# the type's), as for a hot cue; the hot-cue code + RGB stay zero.
if memory >= MAX_MEMORY_CUES: if memory >= MAX_MEMORY_CUES:
continue continue
memory += 1 memory += 1
code, rgb = 0, (0, 0, 0) code, rgb = 0, (0, 0, 0)
color_id = memory_palette.anlz_byte(memory_palette.nearest_code(cue.color)) color_id = memory_palette.anlz_byte(memory_palette.nearest_code(effective_color(cue)))
else: else:
# What Konduktor SHOWS — stored colour, else the type's (blue cue, # What Konduktor SHOWS — stored colour, else the type's (blue cue,
# green loop) — as a rekordbox palette CODE, which is what # green loop) — as a rekordbox palette CODE, which is what
@@ -213,14 +213,15 @@ class RekordboxExporter:
for cue in sorted(item.cues.cues, key=lambda c: c.start): for cue in sorted(item.cues.cues, key=lambda c: c.start):
if cue.role == "memory" or cue.slot is None: if cue.role == "memory" or cue.slot is None:
# rekordbox keeps 10 (earliest first; the rest are # rekordbox keeps 10 (earliest first; the rest are
# dropped, per the lossiness rule). Colour: the memory # dropped, per the lossiness rule). Colour: what
# palette's nearest swatch, else rekordbox's "unset". # Konduktor SHOWS — stored, else the type's — as the
# nearest of the memory palette's 8, as for a hot cue.
if memory >= store.MAX_MEMORY_CUES: if memory >= store.MAX_MEMORY_CUES:
continue continue
store.add_memory_cue( store.add_memory_cue(
track_id, start_sec=cue.start, cue_type=cue.type, track_id, start_sec=cue.start, cue_type=cue.type,
length_sec=cue.length, name=cue.name, length_sec=cue.length, name=cue.name,
color_code=memory_palette.nearest_code(cue.color), color_code=memory_palette.nearest_code(effective_color(cue)),
) )
memory += 1 memory += 1
continue continue
@@ -175,6 +175,10 @@ def to_track(e) -> Track:
) )
#: Traktor's NAME for a cue nobody named.
UNNAMED = "n.n."
def is_memory_cue(c) -> bool: def is_memory_cue(c) -> bool:
"""A cue on no pad that is not a grid marker — Traktor's memory cue. """A cue on no pad that is not a grid marker — Traktor's memory cue.
@@ -248,7 +252,10 @@ def to_track_cues(entry, offset_ms: float = 0.0) -> TrackCues:
slot = c.hotcue if c.hotcue is not None and c.hotcue >= 0 else None slot = c.hotcue if c.hotcue is not None and c.hotcue >= 0 else None
cues.append( cues.append(
CuePoint( CuePoint(
name=c.name, # "n.n." is the name Traktor gives every cue the user did not
# name — a placeholder, not a name, so it crosses as none
# (it once landed in rekordbox as a comment reading "n.n.").
name=None if c.name in (None, "", UNNAMED) else c.name,
# An unknown TYPE is projected as a plain cue rather than dropped: # An unknown TYPE is projected as a plain cue rather than dropped:
# preserving a cue we cannot name beats hiding it from the user. # preserving a cue we cannot name beats hiding it from the user.
type=NATIVE_TO_CUE_TYPE.get(c.type, "cue"), type=NATIVE_TO_CUE_TYPE.get(c.type, "cue"),
+9 -2
View File
@@ -236,7 +236,10 @@ def _real_cue_tags(path: Path) -> list[bytes]:
def _mask_colour(tag: bytes) -> bytes: def _mask_colour(tag: bytes) -> bytes:
"""A PCO2 tag with each entry's code + RGB (after its comment) zeroed.""" """A PCO2 tag with each entry's colours zeroed: the hot-cue code + RGB
(after its comment) and byte 28, a memory cue's colour. The fixture's
memory loop is uncoloured; Konduktor now exports one in its TYPE colour,
as it draws it (decided 2026-10-16) — pinned separately below."""
if tag[:4] != b"PCO2": if tag[:4] != b"PCO2":
return tag return tag
out, off = bytearray(tag), struct.unpack(">I", tag[4:8])[0] out, off = bytearray(tag), struct.unpack(">I", tag[4:8])[0]
@@ -244,6 +247,7 @@ def _mask_colour(tag: bytes) -> bytes:
length = struct.unpack(">I", tag[off + 8:off + 12])[0] length = struct.unpack(">I", tag[off + 8:off + 12])[0]
at = off + 44 + struct.unpack(">I", tag[off + 40:off + 44])[0] at = off + 44 + struct.unpack(">I", tag[off + 40:off + 44])[0]
out[at:at + 4] = bytes(4) out[at:at + 4] = bytes(4)
out[off + 28] = 0
off += length off += length
return bytes(out) return bytes(out)
@@ -468,6 +472,8 @@ check("rekordbox keeps 10 memory cues: the earliest 10 are exported",
check("a memory cue's colour is byte 28 from its own palette (Red = 2); no hot-cue code", check("a memory cue's colour is byte 28 from its own palette (Red = 2); no hot-cue code",
(mem_dicts[0]["color_id"], mem_dicts[0]["code"]) == (memory_palette.anlz_byte(1), 0), (mem_dicts[0]["color_id"], mem_dicts[0]["code"]) == (memory_palette.anlz_byte(1), 0),
(mem_dicts[0]["color_id"], mem_dicts[0]["code"])) (mem_dicts[0]["color_id"], mem_dicts[0]["code"]))
check("an uncoloured one exports in its type colour, as Konduktor shows it (cue -> Blue = 7)",
mem_dicts[1]["color_id"] == memory_palette.anlz_byte(6), mem_dicts[1]["color_id"])
dat_tags = W.cue_tags(mem_dicts[:3], extended=False) dat_tags = W.cue_tags(mem_dicts[:3], extended=False)
mem_pcob = A_.raw_entries(A_.Tag("PCOB", dat_tags[1])) mem_pcob = A_.raw_entries(A_.Tag("PCOB", dat_tags[1]))
check("a memory PCOB of two or more is linked, status 0, as rekordbox writes it", check("a memory PCOB of two or more is linked, status 0, as rekordbox writes it",
@@ -609,7 +615,8 @@ check("four cue rows: three hot cues and a memory cue (Kind 0)",
check("a plain cue is rekordbox's light blue (code 5)", by_kind.get(1) == (0x05, -1), by_kind.get(1)) check("a plain cue is rekordbox's light blue (code 5)", by_kind.get(1) == (0x05, -1), by_kind.get(1))
check("a loop is rekordbox's green (code 22)", by_kind.get(2) == (0x16, -1), by_kind.get(2)) check("a loop is rekordbox's green (code 22)", by_kind.get(2) == (0x16, -1), by_kind.get(2))
check("the white grid cue has no swatch, so stays uncoloured", by_kind.get(3) == (None, -1), by_kind.get(3)) check("the white grid cue has no swatch, so stays uncoloured", by_kind.get(3) == (None, -1), by_kind.get(3))
check("the memory cue is written, uncoloured", by_kind.get(0) == (None, -1), by_kind.get(0)) check("an uncoloured memory cue is written in its type colour (cue -> Blue, Color 6)",
by_kind.get(0) == (None, 6), by_kind.get(0))
check("the contentCue mirror holds all four, colours included", check("the contentCue mirror holds all four, colours included",
mirror is not None and mirror[0].count('"Kind"') == 4 and '"ColorTableIndex": 22' in mirror[0].replace(":22", ": 22"), mirror is not None and mirror[0].count('"Kind"') == 4 and '"ColorTableIndex": 22' in mirror[0].replace(":22", ": 22"),
mirror and mirror[0][:200]) mirror and mirror[0][:200])
+2
View File
@@ -166,6 +166,8 @@ with tempfile.TemporaryDirectory() as d:
count_before = adapter.track(tid2).cue_count count_before = adapter.track(tid2).cue_count
tc = adapter.add_memory_cue(tid2, start_sec=33.0, cue_type="fade_in") tc = adapter.add_memory_cue(tid2, start_sec=33.0, cue_type="fade_in")
mem = [c for c in tc.cues if c.role == "memory"] mem = [c for c in tc.cues if c.role == "memory"]
check("an unnamed cue (Traktor's \"n.n.\") projects with no name",
mem[0].name is None if mem else False, str(mem))
check("add_memory_cue returns fresh cues with the memory cue, by id", check("add_memory_cue returns fresh cues with the memory cue, by id",
len(mem) == 1 and mem[0].slot is None and mem[0].id and mem[0].type == "fade_in" len(mem) == 1 and mem[0].slot is None and mem[0].id and mem[0].type == "fade_in"
and abs(mem[0].start - 33.0) < 0.001, str(mem)) and abs(mem[0].start - 33.0) < 0.001, str(mem))