Music language models write notes as tokens: one token for pitch 60, another for pitch 61, another for a 230-millisecond duration. The standard training loss, cross-entropy over a flat vocabulary, treats every wrong token as equally wrong. Predicting C♯ when the answer was C costs exactly as much as predicting a note three octaves away. Listeners do not judge music that way. A note a few milliseconds late sounds human, while a wild pitch leap sounds broken. Common objective scores such as Fréchet Music Distance, which compares statistics of model embeddings, are largely blind to this difference too. This note proposes that part of the well-documented gap between objective music metrics and human judgment comes from the geometry of errors: whether a model's mistakes are near-misses or gross jumps. It also proposes that this geometry can be controlled cheaply by writing ordered musical values in a Gray code, a binary code in which neighbouring values differ by exactly one bit.
The concrete proposal has three parts. First, take the performance-timed symbolic music tokens of Agogic. Second, replace their flat categories for pitch, duration, velocity and time-shift with short Gray-coded bit groups on both the input and output side. Third, test two things: whether this shifts generated errors toward near-misses, and whether listeners reward that shift when Fréchet Music Distance does not. The skeptic's best alternative is distance-aware label smoothing on the ordinary vocabulary. The experiments are designed so that this alternative can win, and if it does, that outcome is reported as the finding.
Core Claim
The claim has a scientific half and an engineering half. The scientific half is that, at a fixed error rate, human ratings of generated music depend strongly on how far wrong the errors are, while Fréchet Music Distance depends on it only weakly. This would explain cases where better objective scores fail to predict listener preference. The engineering half is that a Gray-coded value representation lowers the gross-error rate relative to flat cross-entropy. It should also let timing and dynamics resolution increase well beyond Agogic's 10 ms bins, because the representation grows in log size rather than linear size, and neighbouring values share almost all of their representation.
Prior work motivates both halves without testing either. Geometric Iterative Retrieval for Neural Audio Codec Resynthesis names the "geometry-blindness" of flat cross-entropy over audio codec tokens. It responds by giving up discrete tokens in favour of continuous retrieval, and it reports that log-spectral distance saturates while listeners keep preferring finer decodes. We stay discrete and target symbolic values, where the ordering is explicit rather than inferred from codebook geometry. Agogic shows that representation matters more than scale: a 0.8B performance-timed model beats a 27B beat-grid model on Fréchet Music Distance. Its 609 tokens are still unordered categories, though, and the authors leave validation by human listening open. On the metric side, three papers supply the evidence for divergence that our corruption study tries to explain mechanistically. The FreeSound Loop benchmark (Hung et al.) finds that distribution metrics reward texture over rhythmic grammar. Improving Automatic Jazz Melody Generation by Transfer Learning Techniques finds that experts prefer models that score worse statistically. SongEval finds that aesthetic coherence is largely independent of signal fidelity.
Research Program
The method comes from Dense Label Encoding for Boundary Discontinuity Free Rotation Detection. That work replaced a 180-way angle classifier with 8 Gray-coded bits, so that a one-bin miss costs one bit, and it reached 77.37% mean average precision on DOTA against 76.17% for circular smooth labels. The reason Gray rather than ordinary binary comes from older work on genetic search (Representation, Search and Genetic Algorithms): ordinary binary has "Hamming cliffs", meaning adjacent values such as 7 and 8 differ in every bit. The positional-encoding line, Toward Relative Positional Encoding in Spiking Transformers, uses Gray codes of token positions so that relative distance can be read off as Hamming distance inside binary attention. We borrow the same idea but apply it along the value axis. A pitch or a duration is treated as a position on its own ordered line, and its Gray bits become its embedding.
Concretely, each ordered attribute value is written as $n = \lceil \log_2 K \rceil$ Gray bits, where $K$ is the number of bins. On input, the token embedding is the sum of learned per-bit embeddings, plus an attribute-type embedding. Neighbouring durations therefore share all but one component, and rare bins borrow statistics from common neighbours. On output, the model predicts all $n$ bits of a value in one step with independent sigmoid heads, as in Dense Label Encoding, so sequence length does not grow.
The Gray code also has a known weakness that matters here. Flipping its most significant bit reflects a value to the far end of the range, so a single wrong bit can still produce a gross error. We confront this directly by weighting each bit's binary cross-entropy by the largest value jump that flipping it can cause:
$$ \mathcal{L} = \sum_{k=0}^{n-1} w_k \,\mathrm{BCE}(\hat{b}_k, b_k), \qquad w_k \propto 2^{k+1}-1, $$
where $b_k$ is the target's $k$-th Gray bit, $\hat{b}_k$ is the predicted probability of that bit, and $w_k$ is that bit's worst-case displacement in value units. This makes the loss roughly track numerical distance while keeping single-bit locality. The independent-bit head cannot represent every joint uncertainty. For example, it handles hesitation between 7 and 8 cleanly but hesitation between 3 and 12 poorly. We measure this cost rather than assume it away.
Three analyses are built on top of the method. The first is an error-geometry profile computed for every model. On held-out data with the correct previous tokens supplied, we record the distribution of signed errors per attribute and the gross-error rate, meaning pitch errors beyond two semitones that are not octaves, and timing errors beyond 50 ms. On free generations we measure onset-jitter and beat-consistency statistics. The second analysis is a resolution sweep at time bins of 10, 5 and 2.5 ms and at velocity levels of 32 and 128. This tests whether the Gray representation holds quality as flat vocabularies grow sparse. The third is the corruption listening study described under the decisive checks, which tests the scientific claim independently of any trained model.
Baselines
The do-nothing reference is the flat performance-timed representation exactly as in Agogic, fine-tuned from Qwen3.5-0.8B with ordinary cross-entropy. That paper reports Fréchet Music Distance of 159 at 0.8B, against 272–286 for beat-grid representations. All variants are trained on the 86.6k aligned corpus with identical data order, steps and optimizer. Each variant gets the same hyperparameter budget, eight runs over learning rate and the method's own knob. Beating this baseline means a lower gross-error rate and a statistically significant listener preference, with Fréchet Music Distance no worse than about 10%.
The strongest competitor on this question is distance-aware label smoothing on the flat vocabulary. Each target is spread as a discretized Gaussian over neighbouring bins of the same attribute, which is the linear analogue of Circular Smooth Label. It is strongest because it gives exactly the distance-aware output loss we claim matters. Unlike in rotation detection, its output-layer cost is negligible here, since a language model's vocabulary is already huge. Its smoothing width gets the same eight-run sweep. It also receives sinusoidal value-axis input embeddings, so it is not handicapped on input sharing. Gray coding counts as beating it only if it wins on gross-error rate or listener preference at the finest resolution, where flat bins are sparsest. Parity at 10 ms would be expected and is not a failure.
The strongest existing system is PMT-4B. On MidiCaps it reports Fréchet Music Distance of 196, against 314 for MIDI-LLM and 421 for text2midi. We train a flat 4B model under our budget and compare it with the Gray-coded 0.8B model, to test whether scale alone fixes error geometry. No reported human-preference result was found on Lacuna for any performance-timed model.
Two ablations isolate the key ingredients. Standard binary codes with the same bit-weighted loss isolate the Gray property, meaning the absence of Hamming cliffs. A Gray-output-only variant with flat input embeddings separates input-side sharing from output-side locality. An unweighted Gray loss measures how much the reflection weakness costs.
Why not just…?
Why not just scale the flat model? Agogic shows that a 34× scale-up barely moves Fréchet Music Distance for beat-grid tokens. That result concerns the timing representation, though, not near-miss geometry, so it does not settle this question. The flat 4B baseline does. If its gross-error rate and listener scores match the Gray-coded 0.8B model, the engineering half of our claim fails.
Why not just use label smoothing? This is the real threat. On output-side locality we expect it to roughly match Gray coding at 10 ms. Our bet is narrower: at 2.5 ms bins and 128 velocity levels, the log-sized, shared Gray representation degrades less than a sparse flat vocabulary. If smoothing with sinusoidal input embeddings matches Gray coding there too, we report that the geometry of the loss matters and the code form does not. The scientific claim and the corruption study survive either way.
Why not just regress timing and velocity as continuous numbers? Geometric Iterative Retrieval documents that one-step regression is "mean-seeking" and averages multimodal targets into muffled output. Expressive timing is plainly multimodal, since a pianist may push or pull a beat. We expect regression to flatten rubato into an average and will include it in the onset-jitter analysis to show this.
Why not just rerank samples with a reward model? CMI-RewardBench reports that its reward model's musicality and instruction-alignment heads correlate at about 0.85 (Spearman rank correlation), and reranking cannot repair errors a generator makes on every sample. Best-of-N reranking is complementary to our method, so we apply it on top of both the flat and Gray models to check that gains add.
Proposed Experiments and Decisive Checks
The first decisive check needs no trained model. We take held-out human performances from the aligned corpus and inject errors at a matched per-note rate, for example 5%, under four geometries: one-bin near-misses, ±2–5-bin moderate errors, uniform-random gross errors, and Gray reflection errors. We then render all versions with one piano synthesizer, compute Fréchet Music Distance for each, and run a paired listening test with musically trained listeners on SongEval's dimensions of coherence, naturalness and overall musicality. The scientific claim holds if listener ratings separate the geometries strongly while Fréchet Music Distance separates them weakly. If both separate them alike, error geometry is not a source of divergence and the proposal should stop there.
The second check is the full model comparison. All baselines and ablations are run on the aligned corpus test split and on MidiCaps, at every resolution in the sweep. For each, we report Fréchet Music Distance, Jensen–Shannon divergence, the error-geometry profile, and a blind pairwise listening test. As secondary automatic judges, we report the SongEval-trained quality predictor, which reaches Pearson correlation 0.912 with human scores on SongEval but is out of domain for instrumental renders, and the CMI-RM musicality head, which reaches 78.20% agreement on CMI-Pref, with its entanglement caveat. We then regress listener scores on Fréchet Music Distance and on gross-error rate across all models. The claim is supported if gross-error rate explains substantially more variance. The Gray method earns its place only if it beats both flat cross-entropy and tuned label smoothing at the finest resolution on listener preference, with binary codes doing worse, which shows that the absence of Hamming cliffs is the operative ingredient.
References
- Agogic: Performance-Timed Music Tokens for LLM-Native Text-to-Symbolic-Music Generation
- Geometric Iterative Retrieval for Neural Audio Codec Resynthesis
- A Benchmarking Initiative for Audio-domain Music Generation using the FreeSound Loop Dataset
- Improving Automatic Jazz Melody Generation by Transfer Learning Techniques
- SongEval: A Benchmark Dataset for Song Aesthetics Evaluation
- Dense Label Encoding for Boundary Discontinuity Free Rotation Detection
- Representation, Search and Genetic Algorithms
- Toward Relative Positional Encoding in Spiking Transformers
- Arbitrary-Oriented Object Detection with Circular Smooth Label
- CMI-RewardBench: Evaluating Music Reward Models with Compositional Multimodal Instruction