Training a music transcription or score-following network against an unaligned score requires a loss that tolerates expressive timing. Human players stretch and compress tempo (rubato), so the same written note can arrive hundreds of milliseconds early or late. Differentiable dynamic time warping, a relaxation of the classic algorithm that finds the cheapest monotone path through a grid of frame-to-note mismatch costs, provides such a loss. Its cost, however, grows with the product of the two sequence lengths. Practitioners therefore either train on short excerpts or confine the search to a fixed band around the diagonal, and a fixed band is exactly what rubato breaks. We propose a two-level soft alignment. A cheap coarse pass produces a probability, for every region of the grid, that the true path passes through it. The fine, differentiable pass is then computed only where that probability is non-negligible. As a result, the search corridor is narrow where the music is metrically clear and widens automatically where tempo is ambiguous. A boundary check after the fine pass detects when the corridor was too tight and widens it.
The aim is to make whole-piece, end-to-end training through alignment affordable, and to test a secondary claim. Synchronized video of the pianist's hands can act as a second cost channel. It should keep the coarse probabilities sharp when the audio is smeared by reverberation, heavy pedaling or noise. That is the regime where an audio-only corridor would have to become wide and expensive, or would go wrong.
Core Claim
Soft-DTW (Soft-DTW: a Differentiable Loss Function for Time-Series) replaces the hard minimum in the alignment recursion with a smoothed minimum controlled by a temperature $\gamma$. Its gradient with respect to the cost matrix is the matrix $E$ of expected alignments, meaning the probability that each cell lies on the path. The claim is that $E$, computed on a downsampled grid, is a usable and self-correcting map for pruning the full-resolution grid. Concretely, let $E^{c}$ be the coarse expected-alignment matrix, let $\mathrm{up}(\cdot)$ map it to fine resolution, and let $\tau$ be a mass threshold. The fine pass is run only on the kept set
$$K = \mathrm{dilate}_r\big(\{(i,j) : \mathrm{up}(E^{c})_{ij} > \tau\}\big),$$
where $r$ is a small fixed dilation in frames. Cells outside $K$ are treated as having infinite cost. After the fine soft-DTW pass inside $K$, we compute the fine expected-alignment mass on the boundary of $K$, written $\partial K$:
$$\mu_{\partial} = \sum_{(i,j)\in \partial K} E^{f}_{ij}.$$
If $\mu_{\partial}$ exceeds a tolerance $\epsilon$, the corridor is touching probable paths. We then widen it locally and recompute. The pruning decision itself is not differentiated; gradients flow through every kept cell. We do not claim that pruning is differentiable. Our claims are three. First, posterior-shaped pruning with a boundary certificate tracks rubato better than fixed-radius corridors at equal cost. Second, it makes full-piece training cheap enough to beat excerpt-based training. Third, adding a video cost channel shrinks $K$ on degraded audio without losing the path.
Relation to Prior Work
Four lines of work motivate the idea. The first shows that alignment-aware training matters. Deep Declarative Dynamic Time Warping differentiates the optimal path itself via the implicit function theorem. Training a recurrent feature extractor through it cut audio-to-score timing error on MAESTRO/Kernscores from 56 ms to 16 ms. It does so with a solver 15 to 50 times slower than discrete DTW over the full grid. We trade its exact-path gradients for soft gradients at low $\gamma$ in exchange for sub-quadratic cost, and we test whether that trade costs accuracy.
The second line shows that the alignment problem in expressive music is genuinely non-diagonal. On Chopin Mazurkas only 13.1% of tracks have stable tempo, and globally constrained trackers fail where local-periodicity trackers do not (Local Periodicity-Based Beat Tracking for Expressive Classical Piano Music). This constrains the design: any static band, including the provably positive-definite triangular kernels of Fast Global Alignment Kernels, is ruled out as the main mechanism.
The third line supplies the pruning idea, in non-differentiable form. An Improved Hierarchical Approach for Music-to-symbolic Score Alignment prunes a hierarchical hidden Markov model search to 3% of the grid with an adaptive likelihood threshold, but it uses fixed chroma and onset features that cannot be trained. FastDTW, used by Kwon et al., constrains a fixed radius around a coarse hard path. That system reaches 8.62 ms mean onset error on MAPS after the transcription network has been trained separately. Our method is the soft, trainable analogue of the hierarchical approach, with an explicit check that the pruning was safe.
The fourth line is engineering. SoftDTW-CUDA-Torch removes the materialized distance tensor and cuts peak memory by up to 98%. It leaves the operation count quadratic, so it is complementary: we use its fused kernels inside $K$.
On the supervision side, NoteEM trains transcription from unaligned scores by alternating hard DTW pseudo-labels with gradient steps. D3TW shows that end-to-end soft alignment in video needs a discriminative margin to avoid collapsing whole sequences onto one frame. We adopt D3TW's lesson as a constraint. Score-side note durations give a natural anti-collapse prior, which we add as a duration penalty, and we report collapse rates.
For the multimodal component, PianoVAM shows that hand landmarks restore onset detection under 0 dB noise, raising F1 from 57.2% to 89.2%. Its streams were synchronized offline. Deep Canonical Time Warping and Conditional Deep Canonical Time Warping align two continuous streams by alternating DTW with correlation maximization over full grids. We instead keep a single score-to-performance alignment and let audio and video each contribute to its cost.
Research Program
The model has three parts. An audio encoder produces frame-level pitch activations. A hand-landmark encoder over PianoVAM's 3D landmarks produces per-frame key-contact evidence. A score encoder maps score notes, or deadpan score renderings, to the same pitch space. The cost at cell $(i,j)$ is a learned combination of the audio mismatch and the video mismatch between performance frame $i$ and score position $j$. A per-frame gate lets the model down-weight video during occlusion or motion blur, which PianoVAM documents.
The coarse pass runs soft-DTW at roughly 10 frames per second with a higher $\gamma$, so that its posterior spreads over genuinely ambiguous regions. The fine pass runs at full frame rate inside $K$ with a low $\gamma$, to approximate a sharp path. The loss is the fine soft-DTW value plus the duration penalty.
The analysis has three threads. First, we measure how $|K|$ (the number of kept cells) scales with piece length, and how it correlates with local tempo variability computed from ASAP beat annotations. This tests the claim that the corridor widens where rubato is. Second, we record how often the boundary check fires and how much fine-level probability falls outside the first corridor. Third, we sweep $\tau$, $r$ and the coarse $\gamma$, since $\gamma$ sensitivity is a known open problem for soft-DTW.
Baselines
The do-nothing reference is the untrained feature pipeline aligned with standard hard DTW. DecDTW reports this at 56 ms TimeErr (mean absolute onset timing error) on its MAESTRO/Kernscores split. We rerun it on our split rather than borrow the number.
The strongest existing method on audio-to-score accuracy is DecDTW. Its reported TimeErr is 16 ms on melspectrogram features over 193 MAESTRO/Kernscores pieces (Deep Declarative Dynamic Time Warping). We train it on the same split, with the same encoder architecture and the same number of tuning trials as our method, and report wall-clock and memory alongside accuracy. If whole pieces do not fit for DecDTW, we will say so and train it on the excerpt lengths it can handle. Beating it means TimeErr at or below 16 ms on its benchmark at a fraction of its training and inference time. Matching its accuracy at, for example, an order of magnitude less compute is the minimum result we would count as a success.
The strongest system for raw precision is Kwon et al.'s separately trained transcription network followed by FastDTW. It reports 8.62 ms mean and 5.57 ms median onset error on MAPS, with 91.6% of notes within 10 ms. We evaluate on MAPS with identical tolerance windows.
For weak supervision we run NoteEM-style hard-DTW pseudo-labeling with the same encoder and number of epochs. NoteEM reports 87.3% note-level F1 on MAPS versus 86.4% for a supervised baseline. Our transcription F1 is compared at matched data.
Full soft-DTW through SoftDTW-CUDA-Torch's fused mode is the brute-force reference. It gives the exact gradients that our pruning approximates, and it tells us how much accuracy pruning loses and how much time it saves.
The key ablation replaces posterior pruning with a fixed-radius corridor around the coarse hard path, which amounts to FastDTW plus soft-DTW. Radii are matched so that the average $|K|$ is equal. If this ablation ties our method on Maz-style rubato, the posterior-shaped corridor is not the contribution. A second ablation removes the video channel, and a third removes the boundary check.
Why not just…?
Why not just run full soft-DTW with fused GPU kernels? Memory is no longer the obstacle, since peak usage drops from about 8 GB to 161 MB at batch 32 and length 512 (SoftDTW-CUDA-Torch). For a ten-minute piece at 100 audio frames per second against thousands of score positions, the per-step work is on the order of $10^8$ cells, and fused recomputation adds runtime. This is a real threat if GPUs are simply fast enough. We settle it by training both on identical pieces under a fixed GPU-hour budget and comparing final TimeErr, not just per-step speed.
Why not just train on short excerpts? Excerpt boundaries in an unaligned score must come from somewhere, usually a coarse alignment. Excerpts also cut long ritardandi and phrase-level tempo arcs at arbitrary points. Still, this may work almost as well, because most gradient signal is local. We test it directly: full soft-DTW on excerpts of matched total cell count versus whole-piece posterior-pruned training, evaluated on whole pieces. If excerpts tie, we will report the contribution as an inference-time and long-form tool rather than a training advance.
Why not just use FastDTW's fixed corridor with a soft pass inside? This is the closest simple competitor and is our main ablation. Its weakness should appear exactly where the coarse hard path is wrong, such as repeated passages, sustained ritardandi and pedal-smeared onsets. At those points a fixed radius cannot hold two hypotheses, while a posterior can. We stratify errors by local tempo variability on ASAP and by noise level on PianoVAM to see whether that weakness appears.
Why not just keep NoteEM's alternating hard alignment? NoteEM already works, so the question is whether end-to-end gradients add anything beyond better pseudo-labels. D3TW's gain over decoupled Viterbi training on Breakfast (45.7% vs 43.0% frame accuracy) suggests they can, but that was video, not music. The matched NoteEM baseline answers this question for music.
Proposed Experiments
The first experiment reproduces the DecDTW setting on MAESTRO/Kernscores, reporting TimeErr, the percentage of notes within 10, 25 and 50 ms, wall-clock time and kept-cell fraction. It is decisive if posterior pruning reaches around 16 ms while keeping a few percent of the grid, comparable to the 3% the hierarchical model reached. It is also decisive if the fixed-radius ablation at equal $|K|$ is measurably worse on high-rubato pieces.
The second experiment uses ASAP with scores and beat annotations to correlate per-segment corridor width with local tempo variance. It also measures how often the boundary check catches a corridor that missed the path, using ground-truth alignments to confirm the miss.
The third experiment uses PianoVAM. It has no symbolic scores, so we build score-like inputs by rendering each performance's MIDI at a constant tempo with velocities removed. The note correspondence then provides exact ground-truth alignment. We add noise at several levels down to 0 dB, plus synthetic reverberation, and compare audio-only and audio-plus-video costs on TimeErr, $|K|$ and downstream onset F1. PianoVAM's 57.2% audio-only and 89.2% visually corrected F1 at 0 dB serve as reference points, not targets. The claim fails if video does not shrink $|K|$ or reduce error under degradation.
The fourth experiment trains a transcription network from unaligned scores on MAESTRO and evaluates note F1 on MAPS against the NoteEM-style baseline. It reports collapse rates with and without the duration penalty.
References
- Soft-DTW: a Differentiable Loss Function for Time-Series
- Deep Declarative Dynamic Time Warping for End-to-End Learning of Alignment Paths
- Local Periodicity-Based Beat Tracking for Expressive Classical Piano Music
- Fast Global Alignment Kernels
- An Improved Hierarchical Approach for Music-to-symbolic Score Alignment
- Audio-to-score alignment of piano music using RNN-based automatic music transcription
- SoftDTW-CUDA-Torch: Memory-Efficient GPU-Accelerated Soft Dynamic Time Warping for PyTorch
- Unaligned Supervision for Automatic Music Transcription in The Wild
- D3TW: Discriminative Differentiable Dynamic Time Warping for Weakly Supervised Action Alignment and Segmentation
- PianoVAM: A Multimodal Piano Performance Dataset
- Deep Canonical Time Warping
- Conditional Deep Canonical Time Warping