cuthbertLab / music21

music21 is a Toolkit for Computational Musicology
https://www.music21.org/
Other
2.09k stars 395 forks source link

Lilypond converter outputs incorrect indent #540

Open chrisspen opened 4 years ago

chrisspen commented 4 years ago

Exporting sheet music in any format with Lilypond like:

conv = music21.converter.subConverters.ConverterLilypond()
conv.write(score, fmt='lilypond', fp='file.png', subformats=['png'])

forces an indentation on the first line, which is inconsistent with all other export formats generated by Music21.

As explained here, Lilypond adds an indent to the first line by default, and this can be disabled by specifying "\paper { indent=0\cm }".

Searching the code, it looks like there are some pre-defined default headers can contain this syntax. However, they're not actually used by the default Lilypond export code. By default, music21 appears to generate the Lilypond "paper" statement with the LyOutputDefHead class, which is hard-coded to render an empty statement, resulting in Lilypond implicitly inserting a default indent.

Is this a bug or an intentional design?

In my application, I need to be able to remove the indent. I can workaround it by monkey patching LyOutputDefHead to output the correct Lilypond syntax, but it would be nice to have a formal option to enable or disable indentation.

mscuthbert commented 4 years ago

Lilypond support is currently deprecated and was scheduled to be removed from music21 whenever it is I upgrade my test system to MacOS Catalina because the developers did not create a 64-bit version for Mac. However, it looks like a few months ago there's now an "unofficial" 64-bit application so I will not make any move towards removing Lilypond. However, I'm highly unlikely to devote any more (non-paid) development time to Lilypond; but happy to take well-tested patches to add features etc.

Before musescore was available as a free way of going directly from music21 to png/pdf, I had plans for being able to customize Lilypond output further, but those are basically frozen now.

mscuthbert commented 3 years ago

Lilypond support is no longer deprecated, but unlikely to be able to work on this myself. Happy to take well-tested patches.