Menu

Overview

Relevant source files

Purpose and Scope

This document provides a high-level introduction to the sheetmusic repository, a multi-format sheet music conversion system. It covers the system's architecture, core components, file organization, and processing workflow. For detailed information about specific subsystems:

Sources: README.md1-13 ly-to-all.sh1-63


System Purpose

The sheetmusic repository transforms LilyPond musical notation source files (.ly) into six distribution formats optimized for different consumption scenarios: web display, printing, audio playback, and video embedding. The system executes a deterministic conversion pipeline via the ly-to-all.sh script, producing vector graphics, raster images, MIDI data, and multiple audio/video encodings from a single source file.

The repository includes three complete example songs (row, twinkle, happy) demonstrating the full asset generation workflow. All output files are versioned in git (except intermediate .wav files) and accessible via CDN (jsDelivr), enabling direct browser access to rendered sheet music and audio.

Sources: README.md1-6 ly-to-all.sh1-63


High-Level Architecture

System Architecture Diagram

The system follows a single-pass batch processing model where ly-to-all.sh orchestrates all external tools in a fixed sequence. The pipeline splits into two parallel tracks after initial LilyPond compilation: visual processing (SVG → WebP) and audio processing (MIDI → WAV → Opus → WebM).

Sources: ly-to-all.sh1-63


Core Components

Component Interaction Map

Sources: ly-to-all.sh20-62 package.json

Component Responsibilities

ComponentTypePrimary FunctionKey Operations
ly-to-all.shBash scriptPipeline orchestrationFile iteration, tool invocation, intermediate file management
midi-len.jsNode.js scriptDuration calculationMIDI parsing, tick-to-second conversion
svg-bg.jsNode.js scriptSVG modificationXML DOM manipulation, white background injection
lilypondExternal binaryMusic engraving.ly.svg + .mid compilation
fluidsynthExternal binaryAudio synthesisMIDI + soundfont → WAV rendering
ffmpegExternal binaryAudio/video encodingWAV trimming, Opus encoding, WebM muxing
rsvg-convertExternal binaryRasterizationSVG → WebP at 2160px width
FluidR3_GM.sf2Data fileInstrument samplesGM-compatible soundfont for synthesis

Sources: ly-to-all.sh1-63


Repository Structure

File Organization

sheetmusic/
├── ly-to-all.sh          # Main conversion pipeline
├── midi-len.js           # MIDI duration extractor
├── svg-bg.js             # SVG background setter
├── package.json          # Node.js dependencies
├── README.md             # Repository documentation
├── LICENSE-CC0-1.0       # Public domain license
├── LICENSE-0BSD          # Zero-clause BSD license
├── .gitignore            # Excludes *.wav and FluidR3_GM.sf2
│
├── row/                  # "Row, Row, Row Your Boat"
│   ├── row.ly            # LilyPond source
│   ├── row.musicxml      # MusicXML export
│   ├── row.svg           # Vector graphics output
│   ├── row.webp          # Raster image output
│   ├── row.mid           # MIDI output
│   ├── row.opus          # Opus audio output
│   └── row.webm          # WebM video output
│
├── twinkle/              # "Twinkle, Twinkle, Little Star"
│   ├── twinkle.ly
│   ├── twinkle.musicxml
│   ├── twinkle.svg
│   ├── twinkle.webp
│   ├── twinkle.mid
│   ├── twinkle.opus
│   └── twinkle.webm
│
└── happy/                # "Happy Birthday to You"
    ├── happy.ly
    ├── happy.musicxml
    ├── happy.svg
    ├── happy.webp
    ├── happy.mid
    ├── happy.opus
    └── happy.webm

Each song directory contains a complete asset set: one source file (.ly), one optional interchange format (.musicxml), and six generated outputs. The directory structure enables self-contained distribution and CDN hosting via jsDelivr, as indicated by the badge in README.md.

Sources: ly-to-all.sh22-24 README.md3


Processing Workflow

Sequential Pipeline Stages

The ly-to-all.sh script processes each .ly file through ten sequential stages:

Sources: ly-to-all.sh22-62

Stage Details

StageTool/ScriptInputOutputPurpose
1lilypondfile.lyfile.svg, file.midCompile musical notation to graphics and MIDI
2npx svgofile.svgfile.svg (optimized)Remove unnecessary SVG elements
3rsvg-convertfile.svgfile.webpRasterize at 2160px with white background
4svg-bg.jsfile.svgfile.svg (modified)Insert white background rectangle
5xmllintfile.svgfile.svg (formatted)Format XML with UTF-8 encoding
6fluidsynthfile.mid, FluidR3_GM.sf2file.wavSynthesize audio from MIDI
7midi-len.jsfile.midduration valueCalculate exact playback duration
8ffmpegfile.wav, durationfile.tmp.wavfile.wavTrim to exact duration
9ffmpegfile.wavfile.opusEncode to Opus codec
10ffmpegfile.opus, durationfile.webmMux with 256×144 black video

Sources: ly-to-all.sh27-61


Version Requirements

The system requires specific versions of external tools, as documented in ly-to-all.sh5-13:

ToolRequired VersionPurpose
lilypond2.24.4Music notation compiler
librsvg (rsvg-convert)2.61.3SVG to raster converter
libxml2 (xmllint)2.15.1XML formatter
fluidsynth2.5.2MIDI synthesizer
ffmpeg8.0.1Audio/video encoder
node25.5.0JavaScript runtime

These version constraints suggest the pipeline was developed for a controlled environment. Version mismatches may cause compilation errors or output format incompatibilities. For detailed installation instructions, see Dependencies and Setup.

Sources: ly-to-all.sh5-13


Output Format Summary

The pipeline generates six output formats from each .ly source file:

FormatFile ExtensionUse CaseGeneration Method
SVG.svgPrint, web display (scalable)LilyPond → svgo → svg-bg.js → xmllint
WebP.webpWeb display (optimized raster)SVG → rsvg-convert at 2160px
MIDI.midMusical data, playback controlLilyPond direct output
WAV.wavIntermediate audio (not in git)MIDI → fluidsynth → ffmpeg trim
Opus.opusAudio streamingWAV → ffmpeg libopus
WebM.webmVideo platforms, browser embedOpus + synthetic black video

The WebM format (256×144 resolution, black screen) serves as a video container for Opus audio, enabling compatibility with platforms that handle video better than standalone audio files. For detailed format specifications, see Output Formats.

Sources: ly-to-all.sh27-61


Licensing

All repository files are dual-licensed under CC0-1.0 (public domain dedication) or 0BSD (zero-clause BSD), allowing unrestricted use, modification, and distribution without attribution requirements. The dual licensing provides maximum compatibility across jurisdictions and use cases.

Sources: README.md8-12 LICENSE-CC0-1.01-122 LICENSE-0BSD1-15


External References

Sources: README.md3-6