Skip to content
Go back

The transition engine: comparing the exit and entry

Updated:

I need to compare the end of one recording with the start of the next. A song’s catalog key and average tempo are useful shortcuts, but they can describe the wrong part of a transition.

The transition code recommends a gap, crossfade, and possible key shift. Rendering is a separate step, and some saved settings still don’t affect the audio. That distinction matters when auditioning a proposed set.

This is part of Stream of Worship, a series. Previous: Running the Analysis Service: Modal apps and background jobs. Next: The songset constructor.

Which measurements to compare

Component aggregation reads rows marked entry, exit, or entry_exit. If more than one row qualifies, occurrence index and row ID provide a deterministic choice. It doesn’t search every possible join point.

For keys, the pair comparison uses component estimates only when both sides have them. Otherwise it falls back to song-level estimates on both sides. This avoids mixing two kinds of key source in one comparison.

Tempo fallback is more limited than that summary might suggest. For a component-key pair, one missing boundary BPM falls back to that song’s BPM with a warning. If both boundary BPMs are missing, the current calculation produces a zero delta and a warning instead of recovering both song-level values. Song-level pairs use song-level tempos. Missing data can therefore make a pair look easier than it is; the warning is worth reading.

Harmony is a rough guide

The harmony helper maps minor keys to their relative majors and measures shortest distance around the circle of fifths. It searches shifts within two semitones and prefers a smaller shift when distances tie.

That is a convenient compatibility measure, with obvious limits. Relative major and minor aren’t interchangeable musical experiences, and compatible keys don’t guarantee compatible arrangements.

The recommendation code chooses among pivot, relative, direct, transposition, vamp, and direct_modulation. Close keys get a two-beat gap with no crossfade. More distant cases get four-, six-, or eight-second overlaps depending on the branch. The transposition branch is checked before the vamp branch.

These names describe recommendations. The renderer doesn’t synthesize a vamp or construct a pivot-chord passage. Low key confidence adds a warning here; the constructor’s separate validator rejects a nonzero shift when the applicable incoming confidence is known and below 0.6. Missing confidence doesn’t trigger that rejection.

From beats to milliseconds

The render worker’s audio engine uses the incoming item’s recording tempo to convert its gap from beats to milliseconds. It doesn’t consume the constructor’s boundary BPM. If tempo is unavailable, it falls back to one second per requested beat.

With crossfade enabled and a duration set, the gap becomes zero. The incoming start is the previous end plus the gap minus the overlap, clamped at zero. Fade filters shape the overlap, delay filters place the tracks, and FFmpeg mixes them. Optional loudness normalization targets −14 LUFS for the resulting mix.

That is enough to produce a continuous file. It doesn’t check for overlapping vocal lines or choose a better place inside a chorus to make the edit.

Saved settings that don’t change the mix

key_shift_semitones and tempo_ratio are loaded and stored, but the reviewed render worker applies neither. There is no pitch-shift or time-stretch filter in its audio path. The audio engine tests are useful for the implemented timing and filter behavior; they aren’t listening evaluations.

This leaves an awkward gap between scoring and delivery. A proposal can satisfy a harmonic rule through a suggested transposition that the rendered file never receives. I would fix that before presenting transposition as a working audio control.

For now, the practical check is to listen to the rendered transition. A favorable distance or technique label is a reason to try a pair, not a verdict on how it sounds.


Share this post on:

Previous Post
Running the Analysis Service: Modal apps and background jobs
Next Post
The songset constructor: searching within a worship arc