MIDI-to-Strudel Decompilation
- The paper demonstrates a decompilation framework that inverts a compiler by training on synthetic MIDI–Strudel pairs to recover executable and musically faithful programs.
- It leverages grammar-constrained decoding, canonicalization, and reinforcement learning to balance MIDI reconstruction fidelity with readable abstraction.
- Empirical results show high compile rates and effective recognition of musical patterns despite trade-offs between note-level accuracy and idiomatic program structure.
Searching arXiv for the specified papers and closely related work to ground the article. {"query":"id:(Katz et al., 2019) OR id:(Kim et al., 2 Jul 2026) MIDI-to-Strudel decompilation symbolic music decompilation Strudel", "max_results": 10} MIDI-to-Strudel decompilation is the task of recovering an executable, editable Strudel program from symbolic MIDI such that executing the program reconstructs the input performance while preserving human-readable musical structure. In formal terms, it treats Strudel as the high-level source language and MIDI as the low-level target representation , and seeks a decompiler that inverts rendering or compilation. The topic sits at the intersection of neural decompilation, symbolic music modeling, and program synthesis: the general methodology of learning to invert a compiler from synthetic pairs was articulated for code decompilation in "Towards Neural Decompilation" (Katz et al., 2019), and was instantiated directly for symbolic music as MIDI-to-Strudel decompilation in "Decomposer: Learning to Decompile Symbolic Music to Programs" (Kim et al., 2 Jul 2026).
1. Conceptual basis and formal task
The general decompilation template is to assume a compiler , construct synthetic training pairs , and train a model to maximize sequence-to-sequence likelihood:
with autoregressive factorization
In the original neural decompilation formulation, structural and grammatical constraints are not added as auxiliary losses; instead, correctness is enforced outside the model through canonicalization, parsing, recompilation, and verification (Katz et al., 2019).
Mapped to symbolic music, the source language is Strudel and the target is MIDI. The adaptation defines a renderer and trains on pairs . The resulting objective remains maximum-likelihood decompilation, but the acceptance criterion becomes executional rather than textual: a candidate Strudel program is accepted if the rendered MIDI is sufficiently close to the input under an alignment distance 0,
1
with 2 instantiated by note-event matching, dynamic time warping, or piano-roll distances in the proposed adaptation (Katz et al., 2019).
Decomposer gives the concrete problem statement in these terms. The input is a multi-track MIDI segment 3; the output is a Strudel program 4 whose execution by the Strudel renderer 5 produces MIDI 6 that closely matches 7. The work emphasizes that quality is judged jointly by rendered-MIDI faithfulness and code-level readability, because many different Strudel programs can render to similar MIDI and literal event-by-event transliteration is not considered an adequate decompilation target (Kim et al., 2 Jul 2026).
2. Strudel as the target program language
Strudel is described as a JavaScript-based DSL for algorithmic music and live coding. For decompilation, its relevance lies in its capacity to express patterns as compact, editable abstractions rather than as flat note lists. The language represents music as time-queryable patterns with operators for repetition, transformation, layering, and section arrangement. Decomposer identifies several idioms that are especially important for concise reconstruction: timing and tempo operators such as setcpm(bpm / beatsPerCycle), fast(k), slow(k), off(phase, op), and swingBy(step, strength); mini-notation forms for repetition, alternation, subdivision, layering, and rests; pitch and harmony operators such as note(...), n(...) .scale(...), and chord(...) .voicing(); arrangement constructs such as stack(...) and arrange(...); and sound selection through sample banks and GM soundfonts (Kim et al., 2 Jul 2026).
This representation matters because MIDI-to-Strudel decompilation is not merely transcription into a different syntax. The target program is expected to expose musical regularities such as repetition, harmonic reuse, layering, and rhythmic gating. Decomposer explicitly frames readable outputs as ones that reveal “musical patterns, repetition, layering, and harmony rather than spelling out notes one by one” (Kim et al., 2 Jul 2026). A plausible implication is that decompilation quality depends not only on event-level reconstruction but also on choosing a programmatic abstraction level compatible with Strudel’s idioms.
The adaptation derived from neural decompilation makes the same point in compiler-theoretic language. Because many different Strudel programs can realize the same MIDI, it proposes a normal-form canonicalization of Strudel before rendering, so that many-to-one mappings are biased toward concise outputs. It also proposes minimum-description-length selection among valid candidates,
8
subject to verification by recompilation (Katz et al., 2019). This formulation formalizes the distinction between literal reconstruction and idiomatic lifting.
3. Data generation and representation
A central obstacle is the scarcity of naturally paired MIDI–Strudel data. Decomposer reports that only 688 public programs were found, and responds by constructing STRUDEL-SYNTH, a synthetic corpus of 21,174 executable Strudel programs paired with rendered MIDI, split into 20,152 training pairs and 1,022 test pairs. Programs are generated by prompting Claude-Opus-4.6 with two independent seeds: a musical seed specifying attributes such as genre, mood, key, tempo, meter, chords, and instrumentation, and a code-style seed specifying idioms such as labeled mini-notation statements, stack(...), and arrange(...). Generated programs are cleaned by a deterministic regex pass and an AST pass using the Acorn parser, then rendered by a headless Strudel runtime over a 90 s window and trimmed to a complete loop using Knuth–Morris–Pratt. Events are serialized to MIDI with GM and channel-9 drum mappings, and programs are retained only if at least one audible voice survives (Kim et al., 2 Jul 2026).
The resulting corpus has average duration 24.1 s with a range of 2–90 s, average instruments per song 9, average lines of code approximately 52, and coverage of 122/128 GM programs (Kim et al., 2 Jul 2026). These statistics are significant because they define the empirical scope of current MIDI-to-Strudel decompilation systems: short-to-medium symbolic segments with broad but not total instrument coverage, and a code distribution intentionally biased toward executable, idiomatic Strudel.
Representation choices for both MIDI and Strudel are treated as part of the decompilation problem rather than as preprocessing details. Decomposer serializes MIDI into text via MidiToText using instrument-wise lines of pitch@cycle_onset tokens with a header [BPM=… Meter=…]. One cycle is one measure, and onsets are normalized by
0
Drum pitches are rendered as names such as bass_drum and closed_hi_hat, while melodic pitches are rendered as note names such as C4 (Kim et al., 2 Jul 2026). The adaptation in (Katz et al., 2019) proposes an alternative event-token formulation for MIDI based on relative time shifts 1, note-on and note-off events, program changes, control changes, pitch bend, and optional tempo events, together with canonicalizations such as tempo normalization, quantization, velocity binning, canonical channel labeling, and stable sorting of explicit note-on/off events.
For Strudel, the adaptation proposes either token-level decoding or AST-based decoding over a grammar 2, with numeric literals split into digits or abstracted as placeholders to reduce vocabulary (Katz et al., 2019). This mirrors the original code-decompilation paper’s use of name abstraction, digit splitting, and canonical order transformations to reduce vocabulary and improve alignment (Katz et al., 2019). Decomposer, by contrast, uses free-form LLM generation and enforces validity at execution time rather than through explicit grammar constraints (Kim et al., 2 Jul 2026).
4. Model architectures and learning pipelines
The original neural decompilation methodology uses a standard encoder-decoder NMT system with attention in DyNMT/DyNet, one LSTM layer in both encoder and decoder, 100 hidden units, 300-dimensional word embeddings, and beam size 5. Its key methodological contribution is not architectural novelty but a principled pipeline: synthesize source programs from a grammar, compile them into low-level targets, train a seq2seq model to invert the compiler, canonicalize both source and target, and wrap decoding in a verification-and-repair loop (Katz et al., 2019).
For MIDI-to-Strudel, the adaptation preserves the same sequence-to-sequence objective and proposes grammar-constrained decoding or tree decoding over 3, followed by a two-phase pipeline consisting of template generation and template filling. In the first phase, the model predicts a structural Strudel AST with placeholders for numeric or symbolic parameters. In the second, a solver recovers concrete parameters such as tempos, durations, velocities, transposition amounts, loop counts, slice indices, or instrument labels by minimizing the verification distance between rendered and input MIDI (Katz et al., 2019). This proposal carries over the code-decompilation idea of structure-first decompilation followed by constant recovery.
Decomposer implements a different but related architecture. Its policy is an open-weight instruction LLM from the Qwen3 family, in 4B and 8B variants. Training proceeds in two stages. First, supervised fine-tuning on STRUDEL-SYNTH minimizes the standard next-token loss
4
The reported implementation uses LoRA rank 64 with 5, learning rate 6 with cosine schedule, weight decay 0.05, gradient clip 1.0, batch size 128, one epoch, on a single node with 7H100, taking approximately 1.5 hours (Kim et al., 2 Jul 2026).
Second, Decomposer applies reinforcement learning on unpaired MIDI from a mixture of STRUDEL-SYNTH and short LMD fragments. The RL objective is
8
with
9
and component-wise group-normalized advantages under GDPO. For each input, a group of candidates is sampled, component-wise normalized advantages are computed as
0
and a clipped GRPO-style update with KL regularization to a reference policy is applied. The reported hyperparameters are 1, batch size 64, learning rate 2, 10 epochs, KL 3, clip 4, temperature 1.0, and maximum generation length 4096; training on a single node with 5H100 takes about 8 days (Kim et al., 2 Jul 2026).
5. Verification, reward design, and the faithfulness–readability tradeoff
Verification is foundational in both lines of work. In code decompilation, a candidate is recompiled and compared to the original low-level input through program dependence graph isomorphism, followed by template filling for mismatched constants (Katz et al., 2019). In MIDI-to-Strudel decompilation, verification becomes executional and alignment-based. The adaptation proposes accepting a candidate 6 when 7, where 8 may be event-level precision/recall/F1 over note pairs, DTW on pitch or chroma sequences, or 9 distance on piano-roll tensors (Katz et al., 2019).
Decomposer instantiates faithfulness more specifically. Let 0 be the note events in the input MIDI and 1 the notes from executing the candidate program. Using instrument-partitioned bipartite matching with onset tolerance 2 ms, it defines per-instrument precision, recall, and F1, then micro-averages over instruments to obtain the multi-instrument onset F1:
3
Equivalently, one may define a distance 4. Programs must compile to be judged; otherwise both faithfulness and readability are replaced by a negative compilation penalty 5 (Kim et al., 2 Jul 2026).
Readability is treated as a separate optimization target. Decomposer uses a fixed rubric of 6 binary checks 7, giving
8
The checks cover variable reuse, comments, formatting and spacing, mini-notation compression, timing transformations, rhythm structure, layering operators, scale usage, chord voicing, and pitch shift (Kim et al., 2 Jul 2026). This is crucial because a high-fidelity but unreadable note-by-note transliteration can score well on raw reconstruction while failing as decompiled code.
The central controversy in MIDI-to-Strudel decompilation is therefore not whether to optimize reconstruction, but how to avoid collapse to literal transliteration. Decomposer identifies note-by-note output as a core failure mode and mitigates it through three coupled mechanisms: STRUDEL-SYNTH’s emphasis on idiomatic abstractions, supervised warm-start before RL, and explicit readability reward shaping. It states that without SFT, RL collapses to short literal note lists that compile but poorly match inputs and earn low readability; it also reports that increasing the readability weight 9 steadily increases 0 while decreasing 1, with 2 used as the main balance point (Kim et al., 2 Jul 2026). This suggests that the faithfulness–abstraction tradeoff is not incidental but structural.
6. Empirical performance, limitations, and open directions
The original neural decompilation paper reports high success rates for code: approximately 97% success for LLVM IR 3 C after 1–2 iterations, specifically 95.68% after iteration 1 and 97.01% after iteration 2, and approximately 88% success for x86 4 C after 6 iterations. It handles sequences up to 845 input tokens and 286 output tokens for LLVM IR, and up to 668 input tokens and 177 output tokens for x86. The paper also reports that grammar complexity dominates optimization level as a source of difficulty, although results degrade with input length (Katz et al., 2019). These results motivate the feasibility of compiler-inversion methodologies beyond conventional code.
For MIDI-to-Strudel, Decomposer evaluates on STRUDEL-SYNTH, LMD short fragments, longer LMD excerpts, GigaMIDI, NES-MDB, Nottingham, and genre-wise ModArchive analyses. On STRUDEL-SYNTH, the heuristic MIDI5Strudel converter achieves compile rate 1.00, Onset F1 0.99, Frame F1 0.83, Inst F1 0.99, Rubric 0.05, Rank 7.89, and SelfCB 0.72. GPT-5.5 achieves compile rate 0.80, Onset 0.57, Frame 0.63, Inst 0.50, Rubric 0.39, Rank 2.76, and SelfCB 0.47. Decomposer with Qwen3-8B plus SFT and RL achieves compile rate 0.99, Onset 0.73, Frame 0.69, Inst 0.72, Rubric 0.74, Rank 3.83, and SelfCB 0.55 (Kim et al., 2 Jul 2026).
On LMD fragments shorter than 30 s, the heuristic converter achieves compile rate 1.00, Onset 0.95, Frame 0.67, Inst 0.89, Rubric 0.09, Rank 7.62, and SelfCB 0.77; GPT-5.5 achieves 0.82, 0.27, 0.31, 0.23, 0.29, 4.27, and 0.56; Decomposer achieves 0.99, 0.60, 0.53, 0.58, 0.61, 4.12, and 0.47 (Kim et al., 2 Jul 2026). The paper summarizes the tradeoff by stating that Decomposer sharply improves faithfulness over frontier LLMs while maintaining rubric scores comparable to or better than them, and that it is far more readable and diverse than the heuristic converter, whose rubric remains approximately 0.05–0.09 and whose SelfCB is higher, indicating diversity collapse (Kim et al., 2 Jul 2026).
Generalization is also reported in a Best@5 setting selected by Inst F1. Decomposer obtains Onset/Rubric scores of 0.86/0.69 on STRUDEL-SYNTH, 0.70/0.56 on LMD 6 s, 0.35/0.68 on LMD 30–60 s, 0.61/0.56 on GigaMIDI, 0.43/0.61 on NES-MDB, and 0.76/0.45 on Nottingham; the corresponding GPT-5.5 scores are 0.70/0.37, 0.44/0.29, 0.21/0.31, 0.57/0.25, 0.37/0.28, and 0.51/0.28 (Kim et al., 2 Jul 2026). Genre-wise ModArchive results show compile rates approximately 1.00 across 51 genres, with faithfulness highest in electronica and dance styles such as Disco, Jungle, and Minimal, and lower in Jazz, Funk, Chiptune, Orchestral, and Reggae; the paper attributes this to Strudel’s strength for repeated rhythmic patterns and the increased difficulty of expressive timing and dense textures (Kim et al., 2 Jul 2026).
Current limitations are reported at several levels. The adaptation from neural decompilation emphasizes many-to-one mappings, micro-timing and expression, long sequences, instruments and channel mapping, and stochastic operators, proposing mitigations such as normalizing MIDI to a canonical grid, separating expressive layers from structural layers, segmenting long pieces, and fixing seeds for stochastic constructs (Katz et al., 2019). Decomposer identifies expressive timing and nuance, multi-instrument orchestration, long-form structure, rubric coverage, diversity, the absence of grammar-constrained decoding, and user-in-the-loop editing as open directions (Kim et al., 2 Jul 2026). A plausible implication is that future systems may combine the explicit grammar and template-filling machinery proposed in (Katz et al., 2019) with the execution-aware RL framework demonstrated in (Kim et al., 2 Jul 2026), thereby integrating stronger syntactic guarantees with learned readability and faithfulness optimization.