Skip to content

expressport: generate the analysis files, for libraries rekordbox has never analysed #147

Description

@M-Igashi

Part of #115, and the one thing left in it that expressport deliberately does not do. Split out because #145 is the first real request for it, and because the answer "rekordbox has to have analysed the track" now needs an issue number behind it rather than a line in a design document.

Why

expressport builds the stick from two sources. Everything textual comes from collection.xml, and the waveforms come from rekordbox's own .DAT / .EXT / .2EX, copied out of the local analysis cache with only PPTH, the cue sections and the PSSI mask rewritten. That was the right call for the beta: rekordbox's analyser is the reference, and copying it is exact by construction.

It also means expressport cannot write a stick for a library rekordbox has never seen. In #145 that is a Mixxx library converted to collection.xml with mixxx2rekordbox, on Ubuntu, where rekordbox does not even run. The grid and the cues were all there in the XML. Only the waveforms were missing, and there is nothing to point --anlz-dir at.

Generating them ourselves is also what #72 asks for from the other direction: once analysis files can be produced from audio plus an XML, a Traktor or Mixxx library becomes a first-class source and baken stops being a rekordbox accessory for that workflow.

What is already there

More than half of a generated file is code that exists:

Section Where it comes from Status
PPTH the USB path section::set_path
PQTZ / PQT2 XML TEMPO, expanded per beat with the beat-in-bar numbering read-only today (locate::pqtz_summary); needs a writer
PCOB / PCPT, PCO2 / PCP2 XML POSITION_MARK anlz::cues, byte-verified against a real export
PVBR the audio file; CBR case already solved rewrite::set_cbr_pvbr, rewrite::mp3_audio_frames
PSSI rekordbox's phrase detection not reproducible; see below
waveforms the audio the whole of this issue

Decoding is not a new dependency either: baken-core already decodes with symphonia for the BS.1770 measurement (#129), so the same reader can feed a waveform builder.

What has to be worked out

  • Which sections a player actually requires. crate-digger documents PWAV and PWV2 in the .DAT, PWV3, PWV4 and PWV5 in the .EXT, and the three-band set (PWV6, PWV7, PWVC) that arrived with the CDJ-3000. expressport copies all of them today without parsing any, so the inventory has to be confirmed against the local fixture export first, per file type and per rekordbox version.
  • The monochrome pair is the easy half. PWAV is a fixed-size preview and PWV3 a scrolling detail, both height plus a whiteness-ish byte per column. Getting the column rate and the scaling right is fiddly but bounded.
  • The colour waveforms are the real work. PWV4 and PWV5 encode a per-column split into frequency bands, and the three-band CDJ-3000 sections encode another. That means a filterbank and a mapping into the packed representation, and neither is documented as a formula, only as a layout.
  • PSSI cannot be generated. Phrase detection is rekordbox's, and there is no way to infer it. A generated file would omit the section entirely, which is a question for the hardware, not for us: a player that refuses a track without phrase data, or hides the phrase display, or does not care, all change what this feature is worth.
  • Whether the player re-analyses anyway. If a CDJ quietly re-analyses a track whose waveform it dislikes, we will see it as a delay before the colour waveform appears, exactly as Player reports for baken expressport (out of beta since 4.3.0; CDJ-3000 and CDJ-2000NXS2 confirmed) #116 asks testers to report.

Scope

  • A generate module next to rewrite, producing whole AnlzFile values rather than editing parsed ones.
  • Opt-in, and loud about it: a flag along the lines of --generate-analysis, off by default, refusing to run silently for tracks that do have a rekordbox analysis. Copying stays the default whenever a real analysis exists, because it is exact and generating is an approximation.
  • No change to export.pdb, the hashed ANLZ directory or the stick layout. Those are solved.

Tests

  • Against the fixture, per section. Generate from the same audio rekordbox analysed and compare: the section inventory and the header lengths have to match exactly, the grid and the cues byte for byte (both come from the XML), and the waveform columns within a stated tolerance, reported as a max and a mean deviation rather than asserted equal. rekordbox's analyser will not be reproduced sample for sample and the tests should not pretend otherwise.
  • Sources that are not 44.1 kHz stereo 16-bit: mono, 48 kHz, FLAC, ALAC, and a file short enough to fall inside one preview column.
  • Idempotence, as everywhere else in expressport: the second run writes the same bytes.

Hardware, and the order of things

This is blocked behind #116. Nothing should be generated for a real stick until a player has read a stick baken wrote from copied analysis, because otherwise a failure has two possible causes and no way to tell them apart. Once #116 comes back, the go/no-go for this one is its own short list: does the track load, is the grid on the beat, is the waveform there and is it the colour one, is there a re-analysis delay, and does the phrase display behave with no PSSI.

Until then #145 and #72 both have the same answer: prepare the library in rekordbox once, or use the VM route in #145.

Activity

  1. M-Igashi commented on Sep 22, 2026

    @M-Igashi
    OwnerAuthor

    Implemented in #148, opt-in behind --generate-analysis exactly as scoped above: copying stays the default whenever a rekordbox analysis exists, generation only fills the gaps, and the hashed directory, export.pdb and the stick layout are untouched.

    What the measurement side turned up, since the open questions in the body were mostly about that. The corpus was 1070 tracks of a rekordbox 7.2 library with both the analysis files and the audio at hand.

    • Which sections a player gets: everything rekordbox 7 writes except PSSI, in rekordbox's order, with the same header words. PVB2 is never written (FLAC seek table, not needed).
    • The monochrome pair is exact. PWV3 height is floor(31.5 * (column peak / track peak)^2) over the mono mix at 150 columns per second, and the whiteness is 7 - floor(8 * lowpassed peak / peak) with a 150 Hz second-order low-pass. Both reproduce rekordbox on 99.5% or more of the columns. PWAV and PWV2 are RMS-based approximations; rekordbox's own PWAV is not a function of any column statistic I could find.
    • The colour waveforms are approximations, as expected. The three-band bytes are low, mid, high in that order (rekordcrate has it right, the Deep Symmetry doc does not), from second-order crossovers at about 300 Hz and 2.5 kHz with a per-column peak and release; correlation with rekordbox 0.99 / 0.98 / 0.90. PWV5 colours map r = low, g = mid, b = high. PWVC carries a per-track gain in the range rekordbox uses.
    • PQTZ is expanded from TEMPO with rekordbox's rounding (91% of 328 fixture tracks within 1 ms; the remainder is BPM precision the XML rounds to 0.01). PQT2 is written in the empty form rekordbox itself uses on some tracks, because its per-beat body resisted decoding.
    • PSSI is omitted. Whether a player minds is the first hardware question, together with the empty PQT2 and whether the colour waveform shows without a re-analysis delay. Both go to Player reports for baken expressport (out of beta since 4.3.0; CDJ-3000 and CDJ-2000NXS2 confirmed) #116 once a stick written this way has been in a player.

    Still blocked behind #116 for the "ship as default" question, but the code path exists, so a tester with a CDJ can now try a library rekordbox has never seen (#145) and report.

  2. M-Igashi commented on Sep 22, 2026

    @M-Igashi
    OwnerAuthor

    Implemented in #148 and closing with it. --generate-analysis is opt-in, copying stays the default when a rekordbox analysis exists, and the measured rules are recorded in the module docs and in the PR description.

    The questions that only a player can answer (an .EXT with no PSSI and an empty PQT2, and whether the colour waveform is drawn without a re-analysis delay) are now step 2 of the test list in #116. Nothing further is planned here unless a hardware report says the generated files are refused; if so, reopen with the files the player wrote to the stick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions