Engineering

LLMs are good at music theory

Ask a large language model to read a photo of a scrawled chord sheet or sort out a song's form from a rough transcription, and it does something unexpected: it shows real musical judgement. When we wired one up to a real chart parser, a renderer and three audio models to build charts for working bands, the surprises were rarely where we expected them.

Updated

The messy pile every band actually works from

Most bands do not start a rehearsal with pristine, transposable charts. They start with whatever survived the last gig: a phone photo of a handwritten index card, a scanned PDF from a rehearsal book, a typed gig sheet listing twenty songs and keys, a lyric sheet with chord names floating loosely above the words, or an MP3 of a cover they need to learn by Friday.

Existing tools each solve part of that mess and leave the rest behind. PDFs and photos in a group chat preserve handwriting, rhythmic kicks and layout, which is fine until a singer asks to take a tune down a tone at soundcheck. Shared folders fill up with duplicates labelled "final" and "actual final". Songbook apps transpose cleanly and keep everyone on the same page, provided someone sits down and types every bar into a structured format first.

Turning that pile into clean charts is tedious, skilled work. You have to count bars per line, track repeats and codas, notice when a stacked pair of numbers is a time signature, keep rhythmic figures intact, and, if all you have is a recording, listen through the track, work out the form and decide which chord variations belong on the page.

That is the job we gave an LLM when building Import using AI for ChordCast. Underneath, Claude reads the files and writes plain-text charts that the apps render and transpose. What surprised us during development was not that the model could copy printed chord names; optical character recognition has been close to that for years. The surprise was how much genuine musical reasoning the model brought to the messy parts.

Where a language model shows real musical judgement

A good chart is an editorial act, not a literal dump of every note played. When a musician writes a chart for a band, they are constantly making small decisions about harmony, phrasing and readability. Give an LLM clear instructions written in musical terms, and it makes many of the same calls.

Start with keys and spellings. Given a chord progression with no key signature written at the top, the model reliably identifies home and keeps spellings consistent with the key. When it compares its own rendered output against a handwritten source, it understands notation equivalences without getting tripped up: it knows that CΔ7 means Cmaj7 and Cø means Cm7♭5.

It also reads song form the way players count it. Sections in popular music tend to land in 4-, 8- or 16-bar blocks. Rather than writing every chorus and verse out sequentially until a tune sprawls across three pages, the model looks for repeated structures and folds them into repeats, D.S. signs and codas wherever the order remains readable. When a section returns at a different length, it writes that pass out again instead of forcing a confusing jump. Where a single bar or a two-bar pair repeats straight back with the same chords and rhythm, it uses repeat signs (./. or ./|/.) so the band reads the figure as one unit.

Section names come from musical function, not guesswork. Bars with no words are an intro, interlude, solo, break or outro. Sung sections whose words change over the same progression are verses; the one whose words come back the same is the chorus; different chords linking them form a pre-chorus; a contrasting section arriving once, late in the song, is a bridge. And when a recording follows a jazz or blues template, one 12-, 16- or 32-bar form looping pass after pass with solos in the middle, the model writes the form once with a "Solos" cue and any tag or ending, rather than printing six near-identical passes.

Harmony under imperfect conditions is where the theory knowledge really shows. On rough transcriptions from audio, the model tells a pushed chord from a passing bass note: a chord landing on the "and" before beat 3 or before the next bar is marked as a push when a section does it consistently, whereas a fleeting chord lasting an eighth or a beat at the end of a bar is ignored as a passing bass note unless it recurs in the same spot. When one bar disagrees across repeated passes of the same section, the model goes with the passes that agree and checks the bass note. Over a pedal point, where the low note holds steady while chords shift above it, audio chord recognisers wobble and often flatten everything to the pedal note's own chord. Prompted to watch the recogniser's runner-up candidates across passes, the model spots a recurring chord over the bass (say, A♭/B♭ in every fourth bar) and writes proper slash chords instead of one static bar. Similarly, where the recogniser heard Em7 and the song has C/E, the model read the low E against the progression and wrote CM7/E.

Even while working, the model demonstrates that it has the whole song in view. Through a dedicated note tool, it streams brief observations to the musician on the progress screen: the key, the form, a chord or progression worth a look, the groove or how the source is laid out.

Musical instinct needs a parser and a pair of eyes

None of that musical judgement would be safe to ship on its own. Ask a language model to emit a domain-specific chart syntax in a single pass, and it will drop a bar on line four, misplace a repeat sign or invent a token that fails to parse. Making it dependable took a closed verification loop.

The importer runs inside the same worker as the MCP server described in the AI assistants guide, which already holds the app's chart parser, music fonts and rasteriser. Instead of hoping the model writes valid chart text, the system puts the exact same compiler and renderer in the model's hands:

  1. The model writes a complete chart in plain chart text, starting with %TITLE, %KEY, %TEMPO and bar-by-bar chords, sections and rhythms.
  2. It calls check_chart. The server runs the real parser and returns any syntax errors, warnings and a rendered image of the drawn chart.
  3. Because the original source photos stay in the conversation, the model compares the rendered drawing against the source image bar by bar: counting bars per line (a dropped or doubled bar is the most common slip), verifying repeats, endings and time signatures, and checking note values wherever rhythm is written.
  4. If handwriting, an accidental, a time signature or a rhythmic figure is small or crowded, the model calls zoom_source. The rasteriser crops and enlarges that region of the photo or scan up to four times (this works on images, not PDFs) so the model can look closer before committing.
  5. Once errors and unintended warnings are cleared, it commits the chart with save_chart.

Not every task needs the model to type out bars. When a musician uploads a typed setlist or gig sheet with no music on it, the model calls add_blank_charts, and the server generates the empty-bar charts carrying each song's title, key, tempo and artist. make_setlist assembles a setlist only when the source is one or the musician asks for it; a stack of unrelated charts stays just charts.

Testing this loop against rendered sample charts from the codebase surfaced every ambiguity in the chart grammar. Wherever an agent had to guess (that lines start with a barline, how empty bars are written, where a time signature goes and how long it stays in effect, ties across barlines, whole-line endings, chord spellings like CM and C7sus, and how to choose a key), we tightened the syntax documentation inside the prompt until both the model and the parser agreed.

Because an import can take multiple tool turns and musicians often upload files from a phone at rehearsal, the import runs as an independent background job inside a Durable Object. It steps through work via alarms, saving conversation state and files in R2 after every step and streaming numbered JSON events (with a ping every 15 seconds) so a client can disconnect, lock its screen or refresh and resume from the last event number. Transient failures, a busy API, a dropped connection or an unavailable audio service, retry from the last saved step after 10 seconds, 30 seconds, 1 minute, 2 minutes and 5 minutes. Jobs and uploaded files are deleted a week after completion, backed by an eight-day bucket rule. Hard limits keep runs bounded: up to 20 images, PDFs or text files totalling 20 MB (apps convert HEIC to JPEG before upload), up to 3 audio files of 60 MB and 10 minutes each outside that cap, 40 model turns per import, 150 charts and 6 imports a minute per address.

Charting a recording without ever hearing it

The counter-intuitive part of the recording importer is that the LLM never hears a single sample of audio.

Before the assistant even starts, an audio analysis service running on a small GPU on Modal processes the file in about 20 seconds warm (roughly a minute and a half on an M-series laptop CPU). Three specialised models run on the mix and hand back a plain-text table, one row per bar: the bar's start time and duration in seconds, every chord detected and where in the bar it starts, the bass note on every eighth note, loudness estimates across drums, bass, harmony and lead vocal bands, onset markers on every sixteenth, and the words sung in that bar.

The LLM receives that table marked as a recording and treats it the way a seasoned player treats a rough lead sheet scribbled on a train. Building the pipeline taught us, in clear order, what actually mattered.

  1. Bar lines come first. Early experiments used librosa's beat tracker with a guessed bar phase. On a 79 BPM track, it guessed double time (161 BPM), dropped the first bar and pushed every chord a beat late. The chart was recognisable, yet far off. Switching to Beat This (CPJKU, 2024) fixed both the tempo and the downbeats: and caught a single 2/4 bar at the end of an intro that a fixed four-beat grid could never hold.
  2. A trained chord model beats template matching. A chroma template matcher found roots and their order, then guessed sus4s and sevenths almost at random. Moving to lv-chordia gave steady qualities (CM7, E♭M7, Dm7, D♭M7, Fm7, Am7), timed chord changes accurately enough to expose rhythmic pushes inside bars, and heard Em7 where the song has C/E (the model wrote CM7/E).
  3. Teaching the model how songs are built. Even with clean bars and chords, an unguided model rotated a repeating progression by a bar. Once the prompt spelled out how musicians count (4-, 8- and 16-bar phrases, choosing the rotation of a loop that makes sections come out even, treating early vocal entries as pickups rather than shifting bar one), the charts snapped into the way a band actually counts the tune.

One of the sharpest engineering lessons came when we tried removing source separation. Our first pipeline ran Demucs (htdemucs, taking over two minutes on CPU) to split drums, bass, harmony and vocals before running the chord model. When we bypassed separation and fed the raw stereo mix straight into the chord recogniser and frequency-band loudness estimators, the harmony barely budged: detected chords matched the stem-based run 90% of the time on one test song and 84% on the second, with matching roots 94% and 92% of the time. The progressions, pushes and that 2/4 bar all held. On the second track's bridge, the mix-only run even landed closer to the songwriter's own changes (E/G♯, G, D/F♯, G against E/G♯, Em/G, D/F♯, Dm6) than the separated stems had. Only minor details disappeared, such as a C/E in one intro and a passing A♭m7 in one verse.

What collapsed without stems was the form. Without an isolated vocal track, the model could not tell a sung verse from an instrumental interlude or identify the chorus. It mislabelled a pre-chorus as a chorus, merged a chorus and interlude into a 12-bar block, and wrote both songs straight through with numbered verses and no D.S. or coda. Source separation had been buying form, not harmony.

Adding Whisper (small, MIT-licensed code and weights) to fill a final lyrics column solved that cleanly. Placing the words that start in each bar restored the form better than stems ever had. Returning lines immediately separated a chorus from a verse even when their progressions differed by only a single chord in a bar. Four quiet bars that every earlier run had labelled as an instrumental break turned out to be the chorus sung alone. Pickup words starting a beat or a bar early aligned section boundaries on the right downbeat. The three-model pipeline, beats, chords and words directly on the mix, delivered accurate form without slow stem separation. Stems remain useful for a different future job: instrument cues like "guitar in" or transcribing a specific bass line or riff.

Where the model still trips, and why model strength matters

Treating this as solved would be dishonest. Several real weaknesses showed up in testing and remain open problems.

On written material, the early trials focused on straightforward charts, gig sheets and sample notation; dense printed lead sheets, multi-page PDFs and complete songbooks have not yet been put through the same paces. On recordings, the experiments used cleanly produced tracks. Live takes, rubato, odd metres and denser jazz or classical harmony remain untried.

Even on clean studio tracks, four technical seams still show:

  • Downbeat slips around pushes. The beat tracker can still slip by an eighth or half a bar when chords are heavily pushed, including through a whole final chorus. Adding a seconds column to the bar table lets the LLM spot rows that are far too short or long and repair the bar lines, yet those passages still warrant a human look.
  • Silence versus a quiet held chord. Both look almost identical in loudness and chord confidence, so N.C. bars in a quiet break can be an educated guess.
  • Rhythmic hits between chord changes. The sixteenth-note onset column contributed little; written kicks and band hits are not reliably detected from audio.
  • Pushes inside a bar. While the chart syntax has a compact token (<:8) for a push across a barline, a push inside a bar has no shorthand, forcing every bar of a pushed loop to be written out with full rhythmic lengths and ties.

Model capability also made a noticeable, practical difference. In head-to-head runs comparing Claude Opus 5.5 (the default) with Claude Sonnet 5.5, both models got standard charts right: chords, sections, repeats, endings, time changes and multi-image pairs. The gap appeared wherever editorial judgement or visual patience mattered.

On a two-set gig sheet, Opus split the material into two setlists and preserved a written cue that Sonnet dropped. On a chart with a tied rhythmic figure, Opus copied the rhythm cleanly on the first attempt; Sonnet initially omitted it, and even after the prompt stressed that written rhythm is part of the chart, Sonnet misread a dotted eighth and sixteenth as a plain eighth, checked once and declared it a match. Only after gaining zoom_source to enlarge those two lines did Sonnet transcribe the rhythm accurately. On a 3.5-minute recording, Opus produced a tight one-page chart with sensible section names and consistent changes; Sonnet kept stray recogniser chords in the intro and bridge where Opus went with the passes that agreed, pasted whole lyric lines as cues instead of short signposts, and wrote the verse out in full: two pages to Opus's one.

That split also shapes how an advisor tool fits into the workflow: a lighter model can handle straightforward edits or answer a question directly, while calling a stronger model first before making the structural decisions on a recording (the form, chords over a pedal, which pushes belong to the song) or deciphering a cramped page.

Designing an assistant that acts like a good bandmate

When an AI tool sits in front of working musicians, tone and ergonomics matter as much as parser accuracy. A few quiet design rules kept the experience grounded.

First, never expose raw chain-of-thought. A model's internal reasoning is a working scratchpad full of dead ends and second-guessing, which looks alarming when you are waiting for a chart. Instead, the note tool streams three to six short musical notes during an import (at most ten in a job), each capped at one plain sentence of no more than 18 words. The prompt forbids praise, filler about the model or its tools, and vague remarks that could apply to any tune. The model states only what it is sure of, or writes "looks like". At the end, its final message gives two or three plain sentences saying what is ready to add to the library, never claiming it has already been added, followed only by a short list of specific charts and sections the musician should double-check. Checks that passed are never mentioned.

Second, offer the other valid way to write a chart. Music notation often has two defensible answers: a jazz standard written as one repeating form versus written out pass by pass, or a riff written with pushes versus written out rhythmically on the staff. Rather than forcing the user to type a prompt explaining notation preferences, the assistant calls offer_change to place buttons under the finished result. Tapping a button triggers that alternative layout directly as a follow-up.

Third, make follow-ups work on the charts rather than starting over. Once a musician inspects the draft, and perhaps tweaks a few bars by hand, they can ask for changes. The follow-up sends back the current charts and setlists, the request and only a list of source filenames. Nothing is re-extracted or listened to again. The model opens a file with read_source (a photo, PDF, text file or the saved recording analysis) only when the change genuinely requires checking the original bar.

If you want to see how the loop behaves on your own photos, PDFs or recordings, Import using AI is live at chordcast.app/ai with a newcomer's first import free, and behind Settings → Experimental in the apps.

Questions

Can an LLM transcribe a song from audio on its own?

Not directly in this architecture: the language model never hears raw audio. Three specialised audio models first analyse the stereo mix for downbeats, chords and sung words, producing a bar-by-bar text table. The LLM then applies musical theory and song-structure rules to turn that noisy table into a readable chart.

How do you stop an LLM from dropping bars or inventing chart syntax?

Pair the model with the exact parser and renderer your app uses. After drafting chart text, the model runs check_chart to catch syntax errors and receives back a rendered image of the chart, which it compares bar by bar against the original photo. When writing is tiny or cramped, zoom_source enlarges that section of the image up to four times before the chart is saved.

Why use speech recognition when building a chord chart?

Timestamped lyrics turn out to be a strong signal for song form without running slow audio source separation. Returning lyric lines distinguish a chorus from a verse even when the chords barely change, reveal quiet vocal sections that loudness meters mistake for breaks, and flag pickup words so sections start on the band's actual downbeat.

What kinds of charts or recordings still trip AI up?

Dense printed lead sheets, multi-page songbooks, live recordings, rubato passages, odd metres and dense harmony remain untried or unreliable. Even on clean studio tracks, downbeat trackers can slip around pushed chords, quiet held chords look much like silence, and rhythmic band hits between chord changes are rarely captured in the audio table.