Skip to content

DJ Set Planner: sort a playlist into a harmonic set by key and BPM - #86

Merged
StreamSeb merged 4 commits into
mainfrom
claude/project-thread-bdqd1u-set-planner
Nov 16, 2026
Merged

StreamSeb merged 4 commits into
mainfrom
claude/project-thread-bdqd1u-set-planner

Conversation

@StreamSeb

Copy link
Copy Markdown
Owner

Requested by Seb · project thread

Stacked on #85. This PR is based on #85's branch because it reuses that PR's detection fixes and trackEverywhere(). Merge #85 first. GitHub then retargets this PR to main; if it doesn't, change the base to main by hand.

What

A new tool at /tools/set-planner. Drop a folder or a stack of tracks and the planner:

  1. Analyses each file in the browser (no server load). Files are decoded with Web Audio and then run through the key finder and BPM detector code in a small Web Worker pool (1 to 3 lanes depending on CPU cores), so the page stays responsive.
  2. Sorts the tracks into a harmonic set. The modes are Smoothest mix (lowest total key and tempo cost), Build energy (tempo climbs in steps, with harmonic order within each step) and As added. You can pin the opening track, and move or remove tracks by hand.
  3. Rates every transition (Smooth, Good, Workable or Rough) and shows the Camelot move and the tempo change in percent. Half/double-time matches are recognised.
  4. Exports CSV (UTF-8 with BOM, formula-safe for names that come from tags), an M3U8 with folder-relative paths for rekordbox, Serato, Traktor and VirtualDJ, or a tracklist copied to the clipboard.

How it copes with large crates and bad input:

  • Progress bar with an ETA and a Stop button.
  • Failures are listed per file with the reason and a Retry button.
  • Non-audio files, macOS ._ files and duplicates are skipped, with a notice.
  • Sets are capped at 500 tracks, and files over 300 MB are refused (probably a full mix).
  • Folder drops walk subfolders.
  • The analysed set, without the audio, is saved in localStorage, so it survives a reload.
  • Artist and title come from ID3v2 tags, or from "Artist - Title" file names.

Ordering

src/lib/set-planner.ts has no browser dependencies. The cost of a transition is the Camelot relation plus a tempo penalty:

  • Camelot: same key 0, ±1 is 1, relative 1.5, +2 is 3, diagonal 3.5, clash 6+.
  • Tempo: free up to about 3%, then rising steeply.

The search runs nearest-neighbour from every start, then 2-opt and or-opt moves within a 600 ms budget.

Featured and SEO

  • Desktop menus: All Tools and DJ Tools, with a NEW badge.
  • Mobile menu: a full-width "DJ Set Planner · NEW" tile at the top of Popular tools.
  • Homepage: a featured banner under the hero, a tool card, a hero copy mention and a "Learn more" link.
  • Other links: /tools (grid, ItemList schema and meta), the footer, the sitemap, the key finder result and related tools, the Camelot tool and two guides.
  • Page: title "DJ Set Planner - Sort a Playlist by Key & BPM, Free" with a matching meta description, keywords, canonical URL and OG image. It has WebApplication schema with a featureList, FAQ schema, breadcrumbs, and how-to and explainer copy.
  • Article: /guides/dj-set-planner, "How to Plan a DJ Set by Key and BPM (New Free Set Planner)", which announces the tool and explains how it works.

Tracking

These go to GA4 and Vercel through trackEverywhere(), the same pair as support_clicked:

  • set_planner_files_added (count, source)
  • set_planner_analysis_done (tracks, failed, seconds)
  • set_planner_reordered (mode)
  • set_planner_exported (format, tracks)

set_planner_track_failed (reason) goes to GA4 only, to keep the Vercel event count down. tool_used is sent with set_planner.

Testing

All tests ran in headless Chromium on the mini PC, with royalty-free incompetech.com tracks.

  • 16 real MP3s plus edge cases: a corrupt MP3, a 3 s WAV, an 8 s loop and a JSON file. 17 tracks were analysed in about 8 s, and the two bad files were listed with the right reasons. The JSON file was skipped with a notice. The main thread never blocked for more than about 0.2 s.
  • Folder of 64 tracks in subfolders: this included a readme.txt and a ._ file. It finished in 30 s with a peak JS heap of about 420 MB. The M3U kept the Sub/ paths. Adding the same folder again reported 64 duplicates.
  • Ordering, checked separately: on 30 random 8-track sets compared against brute force, 28 orders were optimal and the other two were within 1.7% on average. 500 tracks sort in about 0.3 s. Build energy only drops tempo within a step, by 3% or less.
  • Other checks: drag-and-drop, reload persistence, CSV and M3U downloads, mode switching and the pinned opener all work. Mobile has no horizontal overflow.
  • Production build: next build passes and the worker chunk loads under next start. tsc is clean. Lint shows the same 5 errors and 3 warnings as main, none in the new files.

🤖 Generated with Claude Code

StreamSeb and others added 3 commits November 16, 2026 15:36
- The BPM detector now reads the tempo from a dropped or chosen audio file
  (MP3, WAV, FLAC, AAC, OGG, M4A), decoded in the browser, next to the
  existing microphone mode. Shows half/double-time reading and the key.
- Short files (loops, clips) are read from the start instead of returning
  nothing; readings under 78 BPM are doubled (slow reading stays as the
  alternative), which fixes half-tempo results on several house/dnb tracks.
- Beatless audio and non-audio files get a clear error.
- bpm_file_analyzed / bpm_file_failed events to GA4 and Vercel via a new
  trackEverywhere() helper.
- Key analyzer title, meta and schema rewritten around "Key Finder".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- /tools/set-planner: drop a folder or many tracks; each is decoded on the
  device and analysed with the key finder and BPM detector code in a small
  Web Worker pool. Progress, ETA, stop, per-file errors with retry,
  duplicate/non-audio skipping, 500-track cap, set saved in localStorage.
- Ordering (src/lib/set-planner.ts): Camelot + tempo transition cost,
  nearest-neighbour from every start plus 2-opt/or-opt within a time
  budget; "Build energy" climbs through tempo steps; pin an opener; manual
  move/remove. Every transition rated.
- Export CSV (formula-safe, BOM), M3U8 with folder-relative paths, copy
  tracklist. Artist/title from ID3v2 or the file name.
- Featured in desktop menus, mobile Popular tools, homepage banner and
  grid, /tools, footer, sitemap; links from key finder, Camelot tool and
  guides. New guide /guides/dj-set-planner. OG image.
- GA4 + Vercel events: set_planner_files_added, _analysis_done,
  _reordered, _exported (GA4 only: _track_failed).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tunetapper Ready Ready Preview Nov 16, 2026 3:50pm UTC

@StreamSeb StreamSeb self-assigned this Nov 16, 2026
@StreamSeb
StreamSeb changed the base branch from claude/project-thread-bdqd1u to main November 16, 2026 15:50
…-bdqd1u-set-planner

# Conflicts:
#	src/app/tools/page.tsx
#	src/lib/analytics.ts
@StreamSeb
StreamSeb merged commit edbd51d into main Nov 16, 2026
2 checks passed

This branch was successfully deployed

1 active deployment
Preview — ed0a9654 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant