Closed 80aff123-9163-4f3e-a93d-4a2f35af9be1 closed 1 year ago
My first guess would be that LilyPond itself could do this, using \displayMusic
python-ly doesn't know about LilyPond's internal music data structures, and they are, well, internal, so while you're free to use them, they are subject to more frequent changes than the base syntax between LilyPond releases, so I think this would be a bad idea.
You could use something like this:
$ cat musicecho.ly
\version "2.24.1"
#(use-modules (ice-9 textual-ports))
#(display-scheme-music (ly:parse-string-expression
(ly:parser-clone)
(get-string-all (current-input-port))))
$ cat << EOF | ~/lilies/2.24.1/bin/lilypond --silent musicecho.ly
{ c' }
EOF
(make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'pitch
(ly:make-pitch 0 0)
'duration
(ly:make-duration 2))))
Would it be out of the scope of this project to request a feature to convert lilypond syntax to lilypond internal scheme representation without the boilerplate?
I am thinking of a command line interface along the lines of
ly "sexps" [filename or stdout]