DEV Community

Jesse Pinkman
Jesse Pinkman

Posted on Originally published at baken.ravers.workers.dev

rekordbox sorts by key or by BPM, never both, and the sort never reaches the CDJ

A warm-up set usually wants two things at once: keys that sit next to each other on the Camelot wheel, and BPM rising inside each key. rekordbox cannot express that, and neither can the players.

Press Sort by Key on a CDJ and the tracks group by key, but inside 1A the BPMs come out in whatever order you dragged them into the playlist. Press Sort by BPM and the BPM lines up while the keys scatter. There is no compound sort in the UI, on the desktop or on the deck.

That is the visible half of the problem. The half that costs you a set is this: sorting on a player is a view. It never changes the order stored in the playlist, and the order stored in the playlist is what a CDJ reads off the USB stick. Toggle Sort by Key on the laptop, export, and the deck plays the original order back at you.

Six tracks, three sorts

Registration order, which is also the stored order:

# Track Key BPM
1 A 1A 130
2 B 2A 124
3 C 1A 124
4 D 2B 130
5 E 2A 128
6 F 2B 124

The same six tracks under each sort:

# Sort by Key Sort by BPM Compound (key → BPM)
1 A · 1A · 130 C · 1A · 124 C · 1A · 124
2 C · 1A · 124 B · 2A · 124 A · 1A · 130
3 B · 2A · 124 F · 2B · 124 B · 2A · 124
4 E · 2A · 128 E · 2A · 128 E · 2A · 128
5 D · 2B · 130 A · 1A · 130 F · 2B · 124
6 F · 2B · 124 D · 2B · 130 D · 2B · 130

Sort by key and the BPM inside 1A and 2B runs 130 → 124, the opposite direction of a warm-up. Sort by BPM and the key walks 1A → 2A → 2B → 2A → 1A → 2B, a tour of the wheel that ignores harmonic adjacency. Only the third column keeps the keys ascending and the BPM rising inside each one.

Where you can write the order

rekordbox exports its library as an XML file, and it will read that file back in as a second tree in the sidebar, the rekordbox xml tree, alongside your real library. The playlists in that file are lists of <TRACK Key="…"/> references, and their order is the stored order.

So the fix is to rewrite the references:

baken rbsort ~/Music/rekordbox/collection.xml
Enter fullscreen mode Exit fullscreen mode

Camelot key ascending as the primary key, BPM ascending as the tiebreaker inside each key group. Tracks with no Camelot key sort after all known keys. Nothing else in the file changes: names, folder structure, Count and Entries attributes and whitespace are all preserved byte for byte, which means running it twice is a no-op and it can safely run on every export.

Your actual library is never touched. The sorted playlists show up in the separate rekordbox xml tree, you drag the one you want into your real playlists, switch to EXPORT mode and write the USB. The deck plays it in that order in its default browse screen, with nothing to do on the night.

Two things worth knowing before you run it. Keys have to be in Camelot notation, which is Preferences → View → Key display format → Alphanumeric; if they are not, the tool stops rather than guessing. And the rekordbox xml tree is a different sidebar tree from Playlists, which is the single most common reason people think nothing happened.

Why not just ask for the feature

Even if rekordbox shipped a compound sort tomorrow, it would be a view, and the CDJ would still read the stored order. The same is true of Auto Gain: rekordbox works out a per-track gain, applies it in performance mode, and never writes it into the file, so a player reading USB has no idea it exists. Anything that lives only in the laptop app does not follow the music onto the deck. The general move is to bake it into the thing that travels.

The tool is baken, MIT, Rust, macOS, Windows and Linux: https://github.com/M-Igashi/baken. rbsort needs nothing but the XML, not even ffmpeg. There is a native Mac app too, which shows the resulting order before it writes anything, but the command line does the same sort and stays free.

Full version of this write-up, which is the canonical one: https://baken.ravers.workers.dev/sort

rekordbox, CDJ and Pioneer DJ are trademarks of AlphaTheta Corporation. This project is not affiliated with or endorsed by AlphaTheta Corporation.

Top comments (0)