mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented export track grid locking
This commit is contained in:
1 parent
2821ba124d
commit
9329236955
16 files changed
+196
-19
No files matched your search
@@ -1536,8 +1536,13 @@ serialization path.** It enforces:
|
|||||||
above all that **`<LOCATION>` is volume-relative** — an export writing host
|
above all that **`<LOCATION>` is volume-relative** — an export writing host
|
||||||
paths would work perfectly on the machine that made it and resolve to nothing
|
paths would work perfectly on the machine that made it and resolve to nothing
|
||||||
at the gig. Also that a flexible multi-marker grid and hot-cue PADS survive,
|
at the gig. Also that a flexible multi-marker grid and hot-cue PADS survive,
|
||||||
grids are not locked, loose tracks get their "Other" playlist, and re-exporting
|
each grid keeps its source's lock, loose tracks get their "Other" playlist, and
|
||||||
into the same folder replaces rather than appends.
|
re-exporting into the same folder replaces rather than appends. **Lock
|
||||||
|
beatgrids** (the run's option): a new set locks by default and remembers being
|
||||||
|
told not to; on, every exported track WITH a grid is locked (never one without
|
||||||
|
— Traktor would never give it a grid), written as Traktor 4.5 writes it
|
||||||
|
(`LOCK="1"` then `LOCK_MODIFICATION_TIME`, ISO, UTC); `test_export_pioneer.py`
|
||||||
|
pins the Rekordbox Library's `Analysed` 233 vs 105.
|
||||||
It then runs a real export end to end (the source library is built with the
|
It then runs a real export end to end (the source library is built with the
|
||||||
exporter itself, so its LOCATIONs point at audio that exists) and pins the
|
exporter itself, so its LOCATIONs point at audio that exists) and pins the
|
||||||
safety rules with teeth: a folder Konduktor did NOT write is refused, and
|
safety rules with teeth: a folder Konduktor did NOT write is refused, and
|
||||||
@@ -1948,8 +1953,23 @@ that number and nothing else — everything derives from it:
|
|||||||
target** for v1, source is whatever library is loaded, **mirror the source
|
target** for v1, source is whatever library is loaded, **mirror the source
|
||||||
folder structure** (so filename collisions cannot happen), playlists are **live
|
folder structure** (so filename collisions cannot happen), playlists are **live
|
||||||
links removable only as a whole**, re-export **clears the destination first**,
|
links removable only as a whole**, re-export **clears the destination first**,
|
||||||
cancel **rolls back**, key notation **mirrors the source**, grids are **not
|
cancel **rolls back**, key notation **mirrors the source**, no whole-library
|
||||||
locked**, no whole-library export.
|
export. Grids were first left **unlocked**, and that went wrong: an exported
|
||||||
|
Traktor entry has no `AUDIO_ID` (Traktor's analysis fingerprint, which cannot
|
||||||
|
be computed), so Traktor re-analyses it on its first load — re-measuring the
|
||||||
|
BPM (a 174 track came back as 87) and drifting the grid. So the run dialog has
|
||||||
|
**Lock beatgrids** (decided 2026-10-19; `ExportSet.lock_grids`, default on,
|
||||||
|
sent with the run and remembered on the set; shown where a target's
|
||||||
|
`PlatformOption.locks_grids`). It rides on the generic `TrackCues.grid_locked`
|
||||||
|
(`exporter._locked`), the flag a source's own lock already arrives in, so off
|
||||||
|
still carries each track's own lock; Traktor writes `LOCK` +
|
||||||
|
`LOCK_MODIFICATION_TIME` (UTC), the Rekordbox Library sets bit 0x80 of
|
||||||
|
`djmdContent.Analysed` (105 -> 233, measured by locking tracks in rekordbox
|
||||||
|
7). The stick formats carry NO lock: rekordbox 7's own device export of two
|
||||||
|
locked tracks left OneLibrary `analysedBits` and the pdb's `u5` at 41, as on
|
||||||
|
every unlocked track (measured on Hardy, 2026-10-19), so neither stick
|
||||||
|
exporter sets `locks_grids`. The Rekordbox ADAPTER does not yet
|
||||||
|
read or write that bit (`grid.lockable` stays false).
|
||||||
Verified against the real collection: Traktor stores `VOLUME="Hardy"` plus a
|
Verified against the real collection: Traktor stores `VOLUME="Hardy"` plus a
|
||||||
**volume-relative** `DIR`, never a host path — so a USB export is portable by
|
**volume-relative** `DIR`, never a host path — so a USB export is portable by
|
||||||
construction, and the `.nml` cannot be written until the destination is known.
|
construction, and the `.nml` cannot be written until the destination is known.
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ class RekordboxExporter:
|
|||||||
computer_only = True
|
computer_only = True
|
||||||
library_filename = "master.db"
|
library_filename = "master.db"
|
||||||
drive_root = False
|
drive_root = False
|
||||||
|
#: `djmdContent.Analysed` bit 0x80 — from `TrackCues.grid_locked`.
|
||||||
|
locks_grids = True
|
||||||
|
|
||||||
def capabilities(self):
|
def capabilities(self):
|
||||||
"""What a Rekordbox library can hold, with no library to read.
|
"""What a Rekordbox library can hold, with no library to read.
|
||||||
@@ -332,7 +334,9 @@ class RekordboxExporter:
|
|||||||
"""
|
"""
|
||||||
rel = new_content.anlz_rel(str(content.UUID))
|
rel = new_content.anlz_rel(str(content.UUID))
|
||||||
content.AnalysisDataPath = rel
|
content.AnalysisDataPath = rel
|
||||||
content.Analysed = 105 # what a rekordbox-analysed track carries
|
content.Analysed = new_content.ANALYSED
|
||||||
|
if item.cues is not None and item.cues.grid_locked:
|
||||||
|
content.Analysed |= new_content.ANALYSED_LOCKED
|
||||||
content.AnalysisUpdated = 1
|
content.AnalysisUpdated = 1
|
||||||
db.flush()
|
db.flush()
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ from . import artwork
|
|||||||
#: only what is written: 0x2C060E.
|
#: only what is written: 0x2C060E.
|
||||||
CONTENT_LINK = 2885134
|
CONTENT_LINK = 2885134
|
||||||
|
|
||||||
|
#: `djmdContent.Analysed` as a rekordbox-analysed track carries it, and the bit
|
||||||
|
#: rekordbox 7 sets beside it when the grid is LOCKED (the padlock in Grid Edit):
|
||||||
|
#: measured 2026-10-19 by locking two tracks — 105 -> 233, nothing else changed.
|
||||||
|
ANALYSED = 105
|
||||||
|
ANALYSED_LOCKED = 0x80
|
||||||
|
|
||||||
|
|
||||||
def anlz_rel(track_uuid: str) -> str:
|
def anlz_rel(track_uuid: str) -> str:
|
||||||
"""`djmdContent.AnalysisDataPath` for a track. Rekordbox derives it from
|
"""`djmdContent.AnalysisDataPath` for a track. Rekordbox derives it from
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ class RekordboxStore(ReplaceGridCommands):
|
|||||||
track_uuid = str(content.UUID)
|
track_uuid = str(content.UUID)
|
||||||
rel = new_content.anlz_rel(track_uuid)
|
rel = new_content.anlz_rel(track_uuid)
|
||||||
content.AnalysisDataPath = rel
|
content.AnalysisDataPath = rel
|
||||||
content.Analysed = 105 # what a rekordbox-analysed track carries
|
content.Analysed = new_content.ANALYSED
|
||||||
content.AnalysisUpdated = 1
|
content.AnalysisUpdated = 1
|
||||||
files = new_content.anlz_files(audio, measured, [] if with_grid else None)
|
files = new_content.anlz_files(audio, measured, [] if with_grid else None)
|
||||||
for suffix, data in files.items():
|
for suffix, data in files.items():
|
||||||
|
|||||||
@@ -242,6 +242,10 @@ class TraktorAdapter:
|
|||||||
# invent one outside Auto Grid), and it occupies pad A — which
|
# invent one outside Auto Grid), and it occupies pad A — which
|
||||||
# silently displaced the imported track's own pad A cue.
|
# silently displaced the imported track's own pad A cue.
|
||||||
self.replace_grid(track_id, markers)
|
self.replace_grid(track_id, markers)
|
||||||
|
if cues.grid_locked:
|
||||||
|
# The source's lock, or an export's "Lock beatgrids". Unlocked, an
|
||||||
|
# added entry (no AUDIO_ID) is re-analysed on its first load.
|
||||||
|
self._store.set_lock(track_id, True)
|
||||||
|
|
||||||
slots = self.capabilities().cues.hotcue_slots
|
slots = self.capabilities().cues.hotcue_slots
|
||||||
taken = {c.slot for c in self.track_cues(track_id).cues if c.slot is not None}
|
taken = {c.slot for c in self.track_cues(track_id).cues if c.slot is not None}
|
||||||
|
|||||||
@@ -66,6 +66,8 @@ class TraktorExporter:
|
|||||||
menu_order = 20
|
menu_order = 20
|
||||||
library_filename = "collection.nml"
|
library_filename = "collection.nml"
|
||||||
drive_root = False
|
drive_root = False
|
||||||
|
#: `LOCK` — honoured from `TrackCues.grid_locked` by `add_tracks`.
|
||||||
|
locks_grids = True
|
||||||
|
|
||||||
def capabilities(self):
|
def capabilities(self):
|
||||||
"""What a Traktor library can hold — answered with no library to read.
|
"""What a Traktor library can hold — answered with no library to read.
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import copy
|
|||||||
import math
|
import math
|
||||||
import threading
|
import threading
|
||||||
import uuid as uuidlib
|
import uuid as uuidlib
|
||||||
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from traktor_nml_utils import (
|
from traktor_nml_utils import (
|
||||||
@@ -1210,9 +1211,19 @@ class TraktorStore:
|
|||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
|
||||||
def set_lock(self, track_id: str, locked: bool) -> None:
|
def set_lock(self, track_id: str, locked: bool) -> None:
|
||||||
|
"""Lock or unlock a track's grid.
|
||||||
|
|
||||||
|
Locking writes what Traktor 4.5 writes (measured 2026-10-19):
|
||||||
|
``LOCK="1"`` plus ``LOCK_MODIFICATION_TIME``, an ISO time in UTC to the
|
||||||
|
second. What Traktor leaves on UNLOCK is unmeasured, so unlocking only
|
||||||
|
removes ``LOCK``, as it always has.
|
||||||
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
entry = self._entry_or_raise(track_id)
|
entry = self._entry_or_raise(track_id)
|
||||||
entry.lock = 1 if locked else None
|
entry.lock = 1 if locked else None
|
||||||
|
if locked:
|
||||||
|
entry.lock_modification_time = (
|
||||||
|
datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S"))
|
||||||
self._note("lock", "on" if locked else "off", track_id)
|
self._note("lock", "on" if locked else "off", track_id)
|
||||||
self.dirty = True
|
self.dirty = True
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,9 @@ class PlatformOption(BaseModel):
|
|||||||
#: As an export TARGET: its library is only ever read on a computer, never
|
#: As an export TARGET: its library is only ever read on a computer, never
|
||||||
#: from a drive — so it does nothing beside a stick format.
|
#: from a drive — so it does nothing beside a stick format.
|
||||||
computer_only: bool = False
|
computer_only: bool = False
|
||||||
|
#: As an export TARGET: its library can store a grid lock, so the export's
|
||||||
|
#: "Lock beatgrids" option means something there.
|
||||||
|
locks_grids: bool = False
|
||||||
|
|
||||||
|
|
||||||
class RemapSample(BaseModel):
|
class RemapSample(BaseModel):
|
||||||
|
|||||||
@@ -433,12 +433,30 @@ def _folder_paths(adapter) -> dict[str, list[str]]:
|
|||||||
# ---- running -----------------------------------------------------------------
|
# ---- running -----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def _locked(cues, lock_grids: bool):
|
||||||
|
"""The cues as exported: with `lock_grids`, a grid is LOCKED.
|
||||||
|
|
||||||
|
The lock rides on the generic `TrackCues.grid_locked`, the same flag a
|
||||||
|
source's own lock arrives in, so a writer reads one signal and never learns
|
||||||
|
which of the two set it. Unlocked Traktor re-analyses an exported track on
|
||||||
|
its first load (it has no AUDIO_ID, which cannot be computed), re-measuring
|
||||||
|
the BPM — a 174 track can come back as 87 — and drifting the grid; a
|
||||||
|
locked grid is left alone. A track with no grid is never locked: that
|
||||||
|
would stop Traktor ever giving it one.
|
||||||
|
"""
|
||||||
|
if lock_grids and cues is not None and cues.grid_markers and not cues.grid_locked:
|
||||||
|
return cues.model_copy(update={"grid_locked": True})
|
||||||
|
return cues
|
||||||
|
|
||||||
|
|
||||||
def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *,
|
def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *,
|
||||||
root_folder: bool = False) -> dict:
|
root_folder: bool = False, lock_grids: bool = False) -> dict:
|
||||||
"""Copy what changed, then write every target's library over the audio.
|
"""Copy what changed, then write every target's library over the audio.
|
||||||
|
|
||||||
`root_folder` nests the playlists in a folder named after the export (the
|
`root_folder` nests the playlists in a folder named after the export (the
|
||||||
"Put exported playlists in a folder" setting); otherwise they sit at the top.
|
"Put exported playlists in a folder" setting); otherwise they sit at the top.
|
||||||
|
`lock_grids` locks every exported track that HAS a grid (`_locked`); off,
|
||||||
|
each track keeps the source's own lock.
|
||||||
|
|
||||||
Rolls back EVERYTHING this run wrote on cancel or on any failure —
|
Rolls back EVERYTHING this run wrote on cancel or on any failure —
|
||||||
including the libraries of targets that had already been written when a
|
including the libraries of targets that had already been written when a
|
||||||
@@ -530,7 +548,7 @@ def run(adapter, export_set, built: ExportPlan, handle: JobHandle, *,
|
|||||||
ExportTrack(
|
ExportTrack(
|
||||||
track=adapter.track(planned.track_id),
|
track=adapter.track(planned.track_id),
|
||||||
destination=target,
|
destination=target,
|
||||||
cues=adapter.track_cues(planned.track_id),
|
cues=_locked(adapter.track_cues(planned.track_id), lock_grids),
|
||||||
art=_cover(adapter, planned.track_id),
|
art=_cover(adapter, planned.track_id),
|
||||||
fingerprint=_fingerprint(planned),
|
fingerprint=_fingerprint(planned),
|
||||||
analysis_cache=cache,
|
analysis_cache=cache,
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ class ExportSet:
|
|||||||
destination: str = "" # OS path of the folder the export is written into
|
destination: str = "" # OS path of the folder the export is written into
|
||||||
playlist_ids: list[str] = field(default_factory=list)
|
playlist_ids: list[str] = field(default_factory=list)
|
||||||
track_ids: list[str] = field(default_factory=list) # loose tracks only
|
track_ids: list[str] = field(default_factory=list) # loose tracks only
|
||||||
|
#: Lock every exported grid, so Traktor does not re-analyse a track on its
|
||||||
|
#: first load (it re-measures the BPM — 174 can come back as 87 — and the
|
||||||
|
#: grid drifts). Remembered per set: it is a decision about this stick.
|
||||||
|
lock_grids: bool = True
|
||||||
created: float = 0.0
|
created: float = 0.0
|
||||||
modified: float = 0.0
|
modified: float = 0.0
|
||||||
|
|
||||||
@@ -170,6 +174,7 @@ def _load(library_id: str) -> dict[str, ExportSet]:
|
|||||||
destination=values.get("destination") or "",
|
destination=values.get("destination") or "",
|
||||||
playlist_ids=list(values.get("playlist_ids") or []),
|
playlist_ids=list(values.get("playlist_ids") or []),
|
||||||
track_ids=list(values.get("track_ids") or []),
|
track_ids=list(values.get("track_ids") or []),
|
||||||
|
lock_grids=bool(values.get("lock_grids", True)),
|
||||||
created=float(values.get("created") or 0.0),
|
created=float(values.get("created") or 0.0),
|
||||||
modified=float(values.get("modified") or 0.0),
|
modified=float(values.get("modified") or 0.0),
|
||||||
)
|
)
|
||||||
@@ -251,7 +256,8 @@ def create(library_id: str, *, name: str, targets: list[str], destination: str)
|
|||||||
|
|
||||||
|
|
||||||
def update(library_id: str, set_id: str, **fields) -> ExportSet | None:
|
def update(library_id: str, set_id: str, **fields) -> ExportSet | None:
|
||||||
"""Rename, retarget or relocate a set. Unknown fields are ignored."""
|
"""Rename, retarget or relocate a set, or change its options. Unknown fields
|
||||||
|
are ignored."""
|
||||||
sets = _load(library_id)
|
sets = _load(library_id)
|
||||||
found = sets.get(set_id)
|
found = sets.get(set_id)
|
||||||
if found is None:
|
if found is None:
|
||||||
@@ -261,6 +267,8 @@ def update(library_id: str, set_id: str, **fields) -> ExportSet | None:
|
|||||||
setattr(found, key, fields[key])
|
setattr(found, key, fields[key])
|
||||||
if fields.get("targets"):
|
if fields.get("targets"):
|
||||||
found.targets = list(dict.fromkeys(fields["targets"]))
|
found.targets = list(dict.fromkeys(fields["targets"]))
|
||||||
|
if fields.get("lock_grids") is not None:
|
||||||
|
found.lock_grids = bool(fields["lock_grids"])
|
||||||
found.modified = time.time()
|
found.modified = time.time()
|
||||||
_save(library_id, sets)
|
_save(library_id, sets)
|
||||||
return found
|
return found
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ from .schemas import (
|
|||||||
FsListing,
|
FsListing,
|
||||||
FsPlace,
|
FsPlace,
|
||||||
UpdateExportSet,
|
UpdateExportSet,
|
||||||
|
RunExport,
|
||||||
AddGridMarker,
|
AddGridMarker,
|
||||||
GridMarkerEdit,
|
GridMarkerEdit,
|
||||||
ReplaceGrid,
|
ReplaceGrid,
|
||||||
@@ -655,6 +656,7 @@ def update_export(set_id: str, body: UpdateExportSet) -> ExportSetOut:
|
|||||||
name=body.name,
|
name=body.name,
|
||||||
targets=body.targets,
|
targets=body.targets,
|
||||||
destination=body.destination,
|
destination=body.destination,
|
||||||
|
lock_grids=body.lock_grids,
|
||||||
)
|
)
|
||||||
return ExportSetOut(**updated.as_dict())
|
return ExportSetOut(**updated.as_dict())
|
||||||
|
|
||||||
@@ -764,14 +766,19 @@ def preview_export(set_id: str) -> ExportPreview:
|
|||||||
|
|
||||||
|
|
||||||
@app.post("/api/exports/{set_id}/run", response_model=JobStatus)
|
@app.post("/api/exports/{set_id}/run", response_model=JobStatus)
|
||||||
def run_export(set_id: str) -> JobStatus:
|
def run_export(set_id: str, body: RunExport | None = None) -> JobStatus:
|
||||||
"""Start the export on a background thread; poll `/api/jobs/{id}`.
|
"""Start the export on a background thread; poll `/api/jobs/{id}`.
|
||||||
|
|
||||||
Planned again HERE rather than trusting whatever the preview showed: a
|
Planned again HERE rather than trusting whatever the preview showed: a
|
||||||
playlist can be edited, a file deleted or a drive unplugged between looking
|
playlist can be edited, a file deleted or a drive unplugged between looking
|
||||||
and clicking, and the plan carries the destination-safety check.
|
and clicking, and the plan carries the destination-safety check.
|
||||||
|
|
||||||
|
The dialog's options arrive with the click and are remembered on the set,
|
||||||
|
so the next export of the same stick starts from the same answer.
|
||||||
"""
|
"""
|
||||||
found = _require_set(set_id)
|
found = _require_set(set_id)
|
||||||
|
if body is not None and body.lock_grids is not None and body.lock_grids != found.lock_grids:
|
||||||
|
found = exports.update(_require_library_id(), set_id, lock_grids=body.lock_grids)
|
||||||
adapter = require_adapter()
|
adapter = require_adapter()
|
||||||
built = exporter.plan(adapter, found)
|
built = exporter.plan(adapter, found)
|
||||||
if built.blocked:
|
if built.blocked:
|
||||||
@@ -779,7 +786,7 @@ def run_export(set_id: str) -> JobStatus:
|
|||||||
# A Konduktor setting, read when the export starts.
|
# A Konduktor setting, read when the export starts.
|
||||||
root_folder = bool(prefs.load_prefs().get("exportRootFolder", False))
|
root_folder = bool(prefs.load_prefs().get("exportRootFolder", False))
|
||||||
job = JOBS.submit("export", lambda handle: exporter.run(
|
job = JOBS.submit("export", lambda handle: exporter.run(
|
||||||
adapter, found, built, handle, root_folder=root_folder))
|
adapter, found, built, handle, root_folder=root_folder, lock_grids=found.lock_grids))
|
||||||
return JobStatus(**job.as_dict())
|
return JobStatus(**job.as_dict())
|
||||||
|
|
||||||
|
|
||||||
@@ -829,6 +836,7 @@ def export_targets() -> list[PlatformOption]:
|
|||||||
removable=bool(getattr(d, "removable", False)),
|
removable=bool(getattr(d, "removable", False)),
|
||||||
drive_root=bool(getattr(exporter, "drive_root", False)),
|
drive_root=bool(getattr(exporter, "drive_root", False)),
|
||||||
computer_only=bool(getattr(exporter, "computer_only", False)),
|
computer_only=bool(getattr(exporter, "computer_only", False)),
|
||||||
|
locks_grids=bool(getattr(exporter, "locks_grids", False)),
|
||||||
))
|
))
|
||||||
# Targets with no reader of their own (the stick's legacy Device Library):
|
# Targets with no reader of their own (the stick's legacy Device Library):
|
||||||
# listed too, or registering one would not make it selectable.
|
# listed too, or registering one would not make it selectable.
|
||||||
@@ -847,6 +855,7 @@ def export_targets() -> list[PlatformOption]:
|
|||||||
removable=bool(getattr(exporter, "drive_root", False)),
|
removable=bool(getattr(exporter, "drive_root", False)),
|
||||||
drive_root=bool(getattr(exporter, "drive_root", False)),
|
drive_root=bool(getattr(exporter, "drive_root", False)),
|
||||||
computer_only=bool(getattr(exporter, "computer_only", False)),
|
computer_only=bool(getattr(exporter, "computer_only", False)),
|
||||||
|
locks_grids=bool(getattr(exporter, "locks_grids", False)),
|
||||||
))
|
))
|
||||||
# Each exporter states its own place; a platform with no exporter (not yet a
|
# Each exporter states its own place; a platform with no exporter (not yet a
|
||||||
# target, shown disabled) goes last. Stable, so equal places keep their order.
|
# target, shown disabled) goes last. Stable, so equal places keep their order.
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ class ExportSetOut(BaseModel):
|
|||||||
destination: str
|
destination: str
|
||||||
playlist_ids: list[str] = []
|
playlist_ids: list[str] = []
|
||||||
track_ids: list[str] = [] # loose tracks only
|
track_ids: list[str] = [] # loose tracks only
|
||||||
|
lock_grids: bool = True
|
||||||
created: float = 0.0
|
created: float = 0.0
|
||||||
modified: float = 0.0
|
modified: float = 0.0
|
||||||
|
|
||||||
@@ -361,6 +362,13 @@ class UpdateExportSet(BaseModel):
|
|||||||
name: str | None = None
|
name: str | None = None
|
||||||
targets: list[str] | None = None
|
targets: list[str] | None = None
|
||||||
destination: str | None = None
|
destination: str | None = None
|
||||||
|
lock_grids: bool | None = None
|
||||||
|
|
||||||
|
|
||||||
|
class RunExport(BaseModel):
|
||||||
|
#: The run dialog's "Lock beatgrids" — remembered on the set. None keeps the
|
||||||
|
#: set's own answer.
|
||||||
|
lock_grids: bool | None = None
|
||||||
|
|
||||||
|
|
||||||
class ExportSetMembers(BaseModel):
|
class ExportSetMembers(BaseModel):
|
||||||
|
|||||||
+44
-4
@@ -174,10 +174,14 @@ check("with its tempo changes",
|
|||||||
check("and its marker positions",
|
check("and its marker positions",
|
||||||
[round(m.start, 3) for m in out_grid.grid_markers]
|
[round(m.start, 3) for m in out_grid.grid_markers]
|
||||||
== [round(m.start, 3) for m in src_grid.grid_markers])
|
== [round(m.start, 3) for m in src_grid.grid_markers])
|
||||||
# Ben's decision: exported grids are NOT locked, so they stay editable like any
|
# A grid crosses with the lock it had: unlocked at the source, unlocked here.
|
||||||
# other track. If Traktor turns out to re-analyse and flatten them, this is what
|
# Locking every grid is the run's "Lock beatgrids" option (below), because
|
||||||
# makes that visible rather than hidden behind a lock.
|
# Traktor DID turn out to re-analyse an unlocked exported track on first load.
|
||||||
check("grids are not locked", not by_title[flexible.title].grid_locked)
|
check("each track keeps its source's lock",
|
||||||
|
[by_title[t.title].grid_locked for t in chosen] == [t.grid_locked for t in chosen],
|
||||||
|
str([(t.title, t.grid_locked, by_title[t.title].grid_locked) for t in chosen]))
|
||||||
|
check("and only a locked one has LOCK written",
|
||||||
|
text.count(' LOCK="1"') == sum(1 for t in chosen if t.grid_locked))
|
||||||
|
|
||||||
src_cues = src.track_cues(cued.id)
|
src_cues = src.track_cues(cued.id)
|
||||||
out_cues = back.track_cues(by_title[cued.title].id)
|
out_cues = back.track_cues(by_title[cued.title].id)
|
||||||
@@ -278,6 +282,42 @@ check("the audio is really there",
|
|||||||
check("the result re-opens as a library",
|
check("the result re-opens as a library",
|
||||||
len(TraktorDriver().open(dest / "collection.nml").tracks) == len(built.exportable))
|
len(TraktorDriver().open(dest / "collection.nml").tracks) == len(built.exportable))
|
||||||
|
|
||||||
|
print("== Lock beatgrids ==")
|
||||||
|
check("a new export set locks by default", exports.get(LIB, eset.id).lock_grids is True)
|
||||||
|
check("and remembers being told not to",
|
||||||
|
exports.update(LIB, eset.id, lock_grids=False).lock_grids is False
|
||||||
|
and exports.get(LIB, eset.id).lock_grids is False)
|
||||||
|
exports.update(LIB, eset.id, lock_grids=True)
|
||||||
|
gridded = src.track_cues(flexible.id).model_copy(update={"grid_locked": False})
|
||||||
|
bare = gridded.model_copy(update={"grid_markers": []})
|
||||||
|
check("on: a grid is locked", exporter._locked(gridded, True).grid_locked)
|
||||||
|
check("on: a track with no grid is not (Traktor would never give it one)",
|
||||||
|
not exporter._locked(bare, True).grid_locked)
|
||||||
|
check("off: the source's own lock is kept",
|
||||||
|
exporter._locked(gridded.model_copy(update={"grid_locked": True}), False).grid_locked
|
||||||
|
and not exporter._locked(gridded, False).grid_locked)
|
||||||
|
lock_dest = Path(tempfile.mkdtemp()) / "LOCKED"
|
||||||
|
lset = exports.create(LIB, name="LOCKED", targets=["traktor"], destination=str(lock_dest))
|
||||||
|
exports.add(LIB, lset.id, playlist_ids=[source_pl.id], track_ids=[ad.tracks[3].id])
|
||||||
|
lset = exports.get(LIB, lset.id)
|
||||||
|
ljob = JOBS.submit("export", lambda h: exporter.run(
|
||||||
|
ad, lset, exporter.plan(ad, lset), h, lock_grids=True))
|
||||||
|
while not ljob.finished:
|
||||||
|
time.sleep(0.02)
|
||||||
|
check("a locked export finishes", ljob.state == "done", f"{ljob.state}: {ljob.error}")
|
||||||
|
ltext = (lock_dest / "collection.nml").read_text(encoding="utf-8")
|
||||||
|
lback = TraktorDriver().open(lock_dest / "collection.nml")
|
||||||
|
with_grid = [t for t in lback.tracks if t.grid_marker_count]
|
||||||
|
check("every exported track with a grid is locked",
|
||||||
|
with_grid and all(t.grid_locked for t in with_grid),
|
||||||
|
str([(t.title, t.grid_locked) for t in lback.tracks]))
|
||||||
|
check("none without one is",
|
||||||
|
not any(t.grid_locked for t in lback.tracks if not t.grid_marker_count))
|
||||||
|
# Measured in Traktor 4.5: LOCK="1" then LOCK_MODIFICATION_TIME, ISO, UTC.
|
||||||
|
check("written as Traktor writes it: LOCK then an ISO LOCK_MODIFICATION_TIME",
|
||||||
|
len(re.findall(r' LOCK="1" LOCK_MODIFICATION_TIME="\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d"',
|
||||||
|
ltext)) == len(with_grid))
|
||||||
|
|
||||||
print("== Konduktor only ever deletes what Konduktor wrote ==")
|
print("== Konduktor only ever deletes what Konduktor wrote ==")
|
||||||
mine = dest / "MY OWN NOTES.txt"
|
mine = dest / "MY OWN NOTES.txt"
|
||||||
mine.write_text("do not delete")
|
mine.write_text("do not delete")
|
||||||
|
|||||||
@@ -146,6 +146,16 @@ for platform, reopen in (
|
|||||||
[by_title[t.title].color for t in chosen] == COLOURS[:len(chosen)],
|
[by_title[t.title].color for t in chosen] == COLOURS[:len(chosen)],
|
||||||
str([by_title[t.title].color for t in chosen]))
|
str([by_title[t.title].color for t in chosen]))
|
||||||
|
|
||||||
|
if platform == "rekordbox":
|
||||||
|
# Measured 2026-10-19: rekordbox 7's grid padlock sets bit 0x80 of
|
||||||
|
# `djmdContent.Analysed` (105 -> 233) and nothing else.
|
||||||
|
analysed = {c.Title: c.Analysed for c in back._store._db.get_content()}
|
||||||
|
check("a locked grid is Analysed 233, an unlocked one 105",
|
||||||
|
[analysed[t.title] for t in chosen]
|
||||||
|
== [233 if src.track_cues(t.id).grid_locked else 105 for t in chosen]
|
||||||
|
and any(src.track_cues(t.id).grid_locked for t in chosen),
|
||||||
|
str([(t.title, analysed[t.title]) for t in chosen]))
|
||||||
|
|
||||||
print(f"-- {platform}: the key was CONVERTED, not copied")
|
print(f"-- {platform}: the key was CONVERTED, not copied")
|
||||||
for track in chosen:
|
for track in chosen:
|
||||||
if not track.key:
|
if not track.key:
|
||||||
|
|||||||
+12
-3
@@ -334,6 +334,8 @@ export interface PlatformOption {
|
|||||||
drive_root?: boolean
|
drive_root?: boolean
|
||||||
/** As an export target: only ever read on a computer, never from a drive. */
|
/** As an export target: only ever read on a computer, never from a drive. */
|
||||||
computer_only?: boolean
|
computer_only?: boolean
|
||||||
|
/** As an export target: its library can store a grid lock. */
|
||||||
|
locks_grids?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditState {
|
export interface EditState {
|
||||||
@@ -740,6 +742,9 @@ export interface ExportSet {
|
|||||||
playlist_ids: string[]
|
playlist_ids: string[]
|
||||||
/** LOOSE tracks only — tracks a referenced playlist supplies are not listed. */
|
/** LOOSE tracks only — tracks a referenced playlist supplies are not listed. */
|
||||||
track_ids: string[]
|
track_ids: string[]
|
||||||
|
/** Lock every exported grid, so Traktor does not re-analyse a track when it
|
||||||
|
* is first loaded. Set from the run dialog and remembered here. */
|
||||||
|
lock_grids: boolean
|
||||||
created: number
|
created: number
|
||||||
modified: number
|
modified: number
|
||||||
}
|
}
|
||||||
@@ -982,7 +987,10 @@ export const api = {
|
|||||||
exports: () => getJSON<ExportSet[]>('/api/exports'),
|
exports: () => getJSON<ExportSet[]>('/api/exports'),
|
||||||
createExport: (body: { name: string; targets: string[]; destination: string }) =>
|
createExport: (body: { name: string; targets: string[]; destination: string }) =>
|
||||||
send<ExportSet>('POST', '/api/exports', body),
|
send<ExportSet>('POST', '/api/exports', body),
|
||||||
updateExport: (id: string, body: Partial<Pick<ExportSet, 'name' | 'targets' | 'destination'>>) =>
|
updateExport: (
|
||||||
|
id: string,
|
||||||
|
body: Partial<Pick<ExportSet, 'name' | 'targets' | 'destination' | 'lock_grids'>>,
|
||||||
|
) =>
|
||||||
send<ExportSet>('PATCH', `/api/exports/${encodeURIComponent(id)}`, body),
|
send<ExportSet>('PATCH', `/api/exports/${encodeURIComponent(id)}`, body),
|
||||||
deleteExport: (id: string) =>
|
deleteExport: (id: string) =>
|
||||||
send<{ deleted: boolean }>('DELETE', `/api/exports/${encodeURIComponent(id)}`),
|
send<{ deleted: boolean }>('DELETE', `/api/exports/${encodeURIComponent(id)}`),
|
||||||
@@ -1013,8 +1021,9 @@ export const api = {
|
|||||||
exportTargets: () => getJSON<PlatformOption[]>('/api/export-targets'),
|
exportTargets: () => getJSON<PlatformOption[]>('/api/export-targets'),
|
||||||
exportPreview: (id: string) =>
|
exportPreview: (id: string) =>
|
||||||
send<ExportPreview>('POST', `/api/exports/${encodeURIComponent(id)}/preview`, {}),
|
send<ExportPreview>('POST', `/api/exports/${encodeURIComponent(id)}/preview`, {}),
|
||||||
runExport: (id: string) =>
|
// The run dialog's options travel with the click; the set remembers them.
|
||||||
send<JobStatus>('POST', `/api/exports/${encodeURIComponent(id)}/run`, {}),
|
runExport: (id: string, body: { lock_grids?: boolean } = {}) =>
|
||||||
|
send<JobStatus>('POST', `/api/exports/${encodeURIComponent(id)}/run`, body),
|
||||||
|
|
||||||
// ---- path remapping (per-collection OS-path prefix translation) ----
|
// ---- path remapping (per-collection OS-path prefix translation) ----
|
||||||
getPathMapping: () => getJSON<PathMapping>('/api/library/path-mapping'),
|
getPathMapping: () => getJSON<PathMapping>('/api/library/path-mapping'),
|
||||||
|
|||||||
@@ -36,11 +36,18 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
|||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
const [job, setJob] = useState<JobStatus | null>(null)
|
const [job, setJob] = useState<JobStatus | null>(null)
|
||||||
const [starting, setStarting] = useState(false)
|
const [starting, setStarting] = useState(false)
|
||||||
|
// Remembered on the set (sent with the click), so a stick's next export
|
||||||
|
// starts from the same answer. Older sets without it read as on.
|
||||||
|
const [lockGrids, setLockGrids] = useState(set.lock_grids ?? true)
|
||||||
const pollRef = useRef<number | null>(null)
|
const pollRef = useRef<number | null>(null)
|
||||||
|
|
||||||
// Platform names for wording the facts the preview and result carry as ids.
|
// Platform names for wording the facts the preview and result carry as ids.
|
||||||
const platforms = useQuery({ queryKey: ['export-targets'], queryFn: api.exportTargets })
|
const platforms = useQuery({ queryKey: ['export-targets'], queryFn: api.exportTargets })
|
||||||
const nameOf = (id: string) => platforms.data?.find((p) => p.platform === id)?.name ?? id
|
const nameOf = (id: string) => platforms.data?.find((p) => p.platform === id)?.name ?? id
|
||||||
|
// Offered only where a target can store a lock — a stick format cannot.
|
||||||
|
const lockable = set.targets.some(
|
||||||
|
(id) => platforms.data?.find((p) => p.platform === id)?.locks_grids,
|
||||||
|
)
|
||||||
|
|
||||||
const preview = useQuery<ExportPreview>({
|
const preview = useQuery<ExportPreview>({
|
||||||
queryKey: ['export-preview', set.id],
|
queryKey: ['export-preview', set.id],
|
||||||
@@ -83,7 +90,8 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
|||||||
const start = async () => {
|
const start = async () => {
|
||||||
setStarting(true)
|
setStarting(true)
|
||||||
try {
|
try {
|
||||||
setJob(await api.runExport(set.id))
|
setJob(await api.runExport(set.id, lockable ? { lock_grids: lockGrids } : {}))
|
||||||
|
qc.invalidateQueries({ queryKey: ['exports'] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onError((e as Error).message)
|
onError((e as Error).message)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -178,6 +186,23 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
|
|||||||
folder’s contents to a drive’s top level.
|
folder’s contents to a drive’s top level.
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{lockable && (
|
||||||
|
<label className="flex cursor-pointer items-start gap-2.5">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="mt-0.5"
|
||||||
|
checked={lockGrids}
|
||||||
|
onChange={(e) => setLockGrids(e.target.checked)}
|
||||||
|
/>
|
||||||
|
<span className="min-w-0">
|
||||||
|
<span className="block text-sm text-text">Lock beatgrids</span>
|
||||||
|
<span className="block text-xs text-faint">
|
||||||
|
Stops tracks being re-analysed when they’re loaded, which can change the
|
||||||
|
BPM or move the grid.
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
<div className="text-xs text-faint">
|
<div className="text-xs text-faint">
|
||||||
Writes a library for {set.targets.map(nameOf).join(' and ')}, sharing one copy
|
Writes a library for {set.targets.map(nameOf).join(' and ')}, sharing one copy
|
||||||
of every track under <span className="font-mono">Contents/</span>, in your own
|
of every track under <span className="font-mono">Contents/</span>, in your own
|
||||||
|
|||||||
Reference in new issue
Block a user