Best Mix
Queue reordering by tempo and musical key, including the octave-normalized tempo math and circle-of-fifths harmonic costs.
Best Mix reorders a queue so consecutive tracks sit well together, using tempo and musical key rather than the order you happened to add them in.
Where Smart Crossfade decides how to join two tracks, Best Mix decides which tracks end up adjacent.
Using it
Trigger Best Mix from the queue. Orchard analyzes the queue, ranks candidate orderings, and rewrites the queue in place. The currently playing track stays where it is; sorting applies to what comes after.
Best Mix operates on up to 50 tracks at a time. Longer queues are handled in that window rather than attempting a global reorder of hundreds of items.
What it uses
Best Mix scores each possible adjacency from two sources:
- Local analysis, the same tempo, key, and energy data Smart Crossfade produces. See Smart Crossfade.
- Catalog metadata, tempo and key looked up through Orchard’s BPM worker, which is backed by GetSongBPM.
Learned audio profiles from the Audio Engine also feed in, and a cloud analysis batch fetch fills gaps where a track has been analyzed elsewhere.
Tempo cost
Tempo comparison is octave-normalized. The ratio between two tempi is halved or doubled until it lands between roughly 0.67 and 1.5, so a 70 BPM track and a 140 BPM track are treated as the close relatives they are rather than as opposites.
Harmonic cost
Key compatibility follows circle-of-fifths logic, with explicit costs.
Within the same mode (major to major, or minor to minor), cost rises with distance around the circle of fifths:
| Circle distance | Cost |
|---|---|
| 0 (same key) | 0 |
| 1 (perfect fifth) | 0.12 |
| 2 | 0.38 |
| 3 or more | 0.55 and up |
Across modes:
| Relationship | Cost |
|---|---|
| Relative major or minor | 0.05 |
| Parallel (same root, different mode) | 0.22 |
| Anything else | 0.35 and up, by pitch distance |
Relative keys score better than parallel keys because they share a key signature outright, which is what makes them sound related.
When either track has no usable key, the harmonic term drops out rather than guessing.
When it does nothing useful
Best Mix needs data. A queue of tracks with no local analysis and no catalog tempo has nothing to sort on, and the result will be close to the original order. Letting a queue sit long enough for background analysis to complete produces noticeably better results than triggering it the instant a queue is built.
Source map
| Path | Role |
|---|---|
src/app/playback/queueTransitionSort.js | Scoring and reorder |
src/app/playback/smartQueueActions.js | Queue-level actions |
src/audio/crossfade/bpmMetadata.js | Catalog tempo and key lookup |
src/audio/crossfade/bpmMetadataStore.js | Local cache of catalog metadata |
src/services/cloudAnalysisSync.js | Batch analysis fetch |
workers/bpm/ | GetSongBPM proxy worker |
Explicit and Age-Restricted Tracks
How Orchard plays age-restricted songs that most YouTube Music clients cannot, and why the explicit flag never changes stream quality.
Smart Crossfade
The beat-matched, phrase-aligned transition engine: confidence tiers, overlap selection, the discarded-music budget, and offline overlap rendering.