-
Notifications
You must be signed in to change notification settings - Fork 0
Music notation on computers
MusicXML is an interchange format for music scores. However, it is too verbose to write by hand. MuseScore is a practical application that supports it.
LilyPond notation is useful for writing simple scores. It is less interchangeable, although python-ly provides limited support for converting to MusicXML.
Below are fragments of LilyPond code for nursery rhymes. For the full code and instructions, see #How to convert LilyPond files. All files are available in my repo.
\relative c' {
\time 6/8
c4. c4. | c4 d8 e4. | e4 d8 e4 f8 | g2. |
c8[ c8 c8] g8[ g8 g8] | e8[ e8 e8] c8[ c8 c8] | g'4 f8 e4 d8 | c2. \fine
}row.webm
Prerequisites:
- lilypond
- librsvg
- fluidsynth
- FluidR3_GM.sf2
- ffmpeg
- python-ly
Example of the full LilyPond code for "Row, Row, Row Your Boat" (row.ly):
\version "2.24.4"
\score {
<<
\chords {
c2. | s2.*3 |
c2. | s2. | g2. | c2.
}
\relative c' {
\time 6/8
c4. c4. | c4 d8 e4. | e4 d8 e4 f8 | g2. | \break
c8[ c8 c8] g8[ g8 g8] | e8[ e8 e8] c8[ c8 c8] | g'4 f8 e4 d8 | c2. \fine
}
>>
\layout {
\autoBreaksOff
indent = #0
line-width = #120
}
\midi {
\tempo 4. = 120
}
}Convert LilyPond to SVG and MIDI:
lilypond --svg -dcrop -dmidi-extension=mid row.lySet the SVG background to white:
rsvg-convert -b white -f svg -o row.cropped.svg row.cropped.svgConvert MIDI to WAV:
fluidsynth -ni /path/to/FluidR3_GM.sf2 row.mid -F row.wavConvert WAV to WebM:
ffmpeg -i row.wav -c:a libopus row.webmConvert LilyPond to MusicXML (extracting only the \relative block):
python3 -c 'import re, sys; print(re.search(r"\\relative.*?{.*?}", open(sys.argv[1]).read(), re.DOTALL).group(0))' row.ly \
| ly musicxml > row.musicxml🧸 Content is available under CC BY-SA 4.0 unless otherwise noted.