Skip to content
Full-Stack & DevOps

Music intelligence pipeline case study

Scorelearn

I built a full-stack music learning workspace that turns uploaded scores and audio, or a score chosen from the library, into interactive notation. Learners can isolate voices, hear selected measures, follow playback on the score and piano, and explore the theory behind the notes.

Role
System design, full-stack implementation, and deployment
Stack
Next.js, TypeScript, Django REST, Celery, PostgreSQL, Redis, Music21
Core constraint
Keep recognized notation, musical interpretation, and audible playback consistent while making uncertainty visible
Delivery state
Live product with active transcription-quality and hardening work
Scorelearn score upload and analysis interface

Engineering brief

Scorelearn combines a media-processing pipeline with an interactive practice workspace. Recognition produces a canonical MusicXML score; the backend derives note identities, theory facts, and playback schedules from that notation. The frontend connects what learners see, select, hear, and study, while generative explanations sit on top of inspectable musical data.

Inputs
PDF, JPEG, PNG, TIFF, WebP, MP3, WAV, and M4A
Outputs
Structured analysis, MusicXML, MIDI, revision-bound playback plans, and learning examples
Surfaces
Score library, upload, analysis, interactive sheet music, piano follow-along, and downloads

System boundary

Django owns recognition, canonical notation, musical interpretation, instrument choices, and selected-line playback plans. Each exploration request checks the notation revision and analysis lifetime before returning note timings and visual-following frames. The browser validates those plans, schedules sampled instruments on the Web Audio clock, and maps playback back to rendered notation. Downloadable MIDI and source recordings remain separate artifacts.

  1. 01Next.js workspace

    Library or upload, voice and range selection, score following, piano, and lessons

  2. 02Django REST API

    Job lifecycle, reusable preparation, revision checks, instruments, and playback APIs

  3. 03Celery pipeline

    Audiveris OMR or Basic Pitch audio transcription

  4. 04Symbolic core

    Canonical MusicXML, note identity, theory, timed sound and visual plans, and MIDI

Critical decisions

Decision 01 / Architecture

Converge every source on a symbolic score

PDFs and images pass through Audiveris optical music recognition; audio passes through Basic Pitch to produce MIDI. Both branches become MusicXML before the rest of the product analyzes or presents them.

Why it matters: analysis, notation, playback, and downloads share one downstream contract instead of duplicating logic for every input type.

Decision 02 / Responsiveness

Model long-running work as an observable job

Uploads dispatch a Celery task through Redis. The worker publishes named stages and progress percentages, while React Query polls the score endpoint and stops only at a terminal state.

Why it matters: expensive recognition never holds an HTTP request open, and a failed validation, transcription, cleanup, or analysis stage remains visible to the user.

Decision 03 / Data quality

Preserve recognized notation and make repairs explicit

Audio transcription passes through timing and density cleanup before becoming a score draft. Visual recognition preserves the recognized notation, with verified reconciliation for supported split-part cases. Instrument label recovery is recorded separately from the canonical score.

Tradeoff: audio cleanup can simplify nuance, and optical recognition remains unverified. Keeping transformations and uncertainty explicit prevents a playable result from being mistaken for a faithful transcription.

Decision 04 / AI boundary

Derive musical facts before generating an explanation

Music21 detects key, meter, tempo, parts, instrumentation, chords, measures, dynamics, accidentals, and articulations. Gemini receives those results afterward to create a concise, beginner-focused explanation.

Why it matters: generative text explains an inspectable analysis payload; it is not asked to infer the score directly from an opaque upload.

Decision 05 / Playback consistency

Build sound and score following from the same verified notation

The backend prepares selected voices on a shared timeline, including supported ties, note timing, tempo changes, repeats, and first/second endings. Plans carry a notation revision, note references, and visual frames. The frontend checks the contract before scheduling audio and highlighting the score, with bounded scheduling for longer selections.

Why it matters: listening and visual following share one musical clock. Unsupported repeat structures fall back to written order with a notice; uncertain timing or pitch produces diagnostics rather than guessed playback.

Decision 06 / Reuse and lifecycle

Prepare library scores once, then isolate each exploration

The library supports search, category and difficulty filters. The backend reuses a prepared source bundle and materializes separate exploration artifacts, with idempotent opening requests, explicit retries, and generation-bound progress. Each analysis session has its own expiry; polling neither starts processing nor extends retention.

Why it matters: reopening a library score can reuse expensive recognition work while keeping instrument choices, failures, and temporary artifacts scoped to each exploration.

Read, listen, and learn

01

Inspect the score

OpenSheetMusicDisplay renders the canonical MusicXML. Learners can select notes, focus voices and measure ranges, and show note names or movable-do solfa where supported. A piano view follows playback, and the MusicXML remains downloadable for other notation tools.

02

Practice directly on the sheet music

The sheet music transport plays one or several selected voices with sampled instruments, pause, resume, seeking, and score following. Learners can use score tempo or set a fixed practice BPM, add a metronome and count-in, and choose instruments per part. Longer selections support ordinary repeats and first/second endings. The separate MIDI player and original audio remain available.

03

Understand the theory

One note and Together modes connect selected notation to melodic intervals, simultaneous intervals, and simple chords, with short listening examples. Analysis separates signatures, structure, and performance details; an on-demand generated explanation adds beginner-focused context.

Production lens

Scorelearn production readiness
ConcernCurrent evidenceBoundary
FrontendNext.js deployed through OpenNext on Cloudflare with a custom domainLive
RuntimeContainerized Django, Celery, PostgreSQL, Redis, and Caddy services with health checksOperational topology
Input safetyExtension and MIME allow-lists, explicit source types, file-size checks, isolated job workspacesImplemented
LifecycleIndependent analysis expiry, shared locks for artifact access and deletion, and reusable library preparationTemporary exploration artifacts expire; polling does not renew them
PlaybackBackend reliability tests, exported API contract fixtures, frontend validation, and playback integration/browser checksUp to 2,000 written measures, 10,000 source notes/rests, 60 minutes including repeats, and 16 simultaneous sounds; supported notation required
AccuracyCleanup metadata, draft labels, stage-specific failures, guidance for unsuitable audioBenchmark against a representative score corpus
OperationsStructured worker stages and progress are exposed to the clientAdd service metrics, tracing, and queue alerts

Music transcription remains probabilistic: clean solo recordings and high-quality scans work better than dense mixes or damaged scores. Synchronized playback follows supported interpretations of the generated notation; it does not establish transcription accuracy or alignment with the original recording. Unknown instruments use piano, unsupported passages expose diagnostics, and temporary playback stops when its analysis expires. Representative recognition benchmarks and broader device acceptance remain areas for further validation.

What this demonstrates

  • Designing a heterogeneous media pipeline around a stable symbolic intermediate representation.
  • Moving CPU-heavy recognition into asynchronous workers with explicit progress, failure, and cleanup states.
  • Combining deterministic music analysis with a deliberately narrow generative explanation layer.
  • Connecting revision-verified backend playback plans to sampled audio, score highlights, piano following, and interactive lessons.
  • Reusing expensive library preparation while isolating exploration state, retries, and artifact retention.
  • Next.js
  • TypeScript
  • Django REST Framework
  • Celery
  • PostgreSQL
  • Redis
  • Audiveris
  • Basic Pitch
  • Music21
  • MusicXML
  • OpenSheetMusicDisplay
  • Tone.js
  • Web Audio API
  • Cloudflare
  • Docker