| Crates.io | strudel-of-lilypond |
| lib.rs | strudel-of-lilypond |
| version | 0.3.0 |
| created_at | 2026-01-17 13:56:10.053093+00 |
| updated_at | 2026-01-19 13:08:44.256415+00 |
| description | Convert LilyPond music notation to Strudel live coding patterns |
| homepage | |
| repository | https://github.com/laurentcarrie/strudel_of_lilypond |
| max_upload_size | |
| id | 2050474 |
| size | 83,301 |
A Rust tool that converts LilyPond music notation to Strudel live coding patterns. LilyPond is a music engraving program that uses text-based notation; Strudel is a JavaScript library for live coding music.
cargo install strudel-of-lilypond
strudel-of-lilypond input.ly # Creates input.html with embedded Strudel REPL
See the demo/ directory for a complete example with:
cargo build # Build the project
cargo run # Run the converter with example input
cargo test # Run all tests
cargo test <name> # Run a specific test (e.g., cargo test test_parse_simple_notes)
The codebase is a Rust library (src/lib.rs) with a CLI frontend (src/main.rs).
Note - Pitched note with name, octave, accidental, duration, and MIDI numberDrumHit - Drum sound with name (bd, hh, sn, etc.) and durationStaff - Either pitched (Vec<PitchedEvent>) or drums (Vec<DrumVoiceData> for simultaneous voices)Tempo - Beat unit and BPM from \tempo markingsParses LilyPond notation with support for:
\tempo 4 = 120 - must be present in inputvoice = { ... })drums = \drummode { ... })\score { << ... >> })\new Staff, \new TabStaff, \new DrumStaff\new DrumVoice inside DrumStaff\repeat unfold/percent N { ... }) → Strudel !N syntax[...] brackets[[[bar1] [bar2]]!2]@4is/es), octave markers ('/,), and durations<c e g>4) → Strudel [c4,e4,g4] syntaxGenerates Strudel patterns:
generate_pitched_staff() - note("c4 d4 e4").s("piano")generate_drum_staff() - sound("bd hh sn hh") or stack() for multiple voicesgenerate_multi() - Multiple $: patterns for simultaneous stavesgenerate_html() - HTML page with embedded Strudel REPL\tempo 4 = 120 - specifies beat unit and BPMc d e f g a bis (sharp), es (flat) - e.g., cis = C#, des = Db' raises octave, , lowers octave (middle C = c')r → ~, r2 → ~ ~ (half rest = two quarter rests)|) define bar groupings in output@4, half=@2, quarter=(none), eighth=@0.5, sixteenth=@0.25Add special comments inside a staff or voice to control Strudel output:
% @strudel-of-lilypond@ <color> punchcard - Enable punchcard visualization with color% @strudel-of-lilypond@ gain <value> - Set gain/volume (supports patterns like <0.5 1 1.5>)% @strudel-of-lilypond@ pan <value> - Set stereo panning (supports patterns like <0 .5 1>)\tempo 4 = 60
\new TabStaff {
% @strudel-of-lilypond@ red punchcard
% @strudel-of-lilypond@ gain 2
% @strudel-of-lilypond@ pan 0.25
\voicea
}
\new DrumStaff {
<<
\new DrumVoice {
% @strudel-of-lilypond@ cyan punchcard
% @strudel-of-lilypond@ pan <0 .5 1>
\kicks
}
\new DrumVoice {
\hats
}
>>
}
This generates Strudel code with the specified modifiers:
const tempo = 60;
$: note("[c4 d4 e4]")
.gain(2)
.pan(0.25)
.color("red")
._punchcard()
.s("piano")
.cpm(tempo/4/1)
$: stack(
sound("[[bd bd]]!2")
.pan("<0 .5 1>")
.color("cyan")
._punchcard(),
sound("[[hh@0.5 hh@0.5 hh@0.5 hh@0.5]]!2"),
)
.cpm(tempo/4/2)
[...] brackets!N syntax: [[bar content]]!3[[[bar1] [bar2]]!2]@4tempo/4/number_of_barstempo constant is defined at the top of the generated code