Package com.softsynth.jmsl.score.util
Class LilyPondWriter
java.lang.Object
com.softsynth.jmsl.score.util.LilyPondWriter
public class LilyPondWriter
extends java.lang.Object
LilyPond is a common music notation interpreter that generates postscript and pdf files from
text-based input (visit www.lilypond.org).
LilyPondWriter exports a JMSL Score to LilyPond GNU LilyPond 2.24.3 (running Guile 3.0) format. Each staff of the JMSL Score is written to its own .ly file, then combined in a full ensemble score by a master .ly file. (According to LilyPond docs, this is the recommended method for creating a full ensemble score, so parts can be transposed and printed separately). So if your LilyPond filename is MyScore.ly, then LilyPondWriter will generate MyScoreStaffAA.ly, MyScoreStaffAB.ly, MyScoreStaffAC.ly, etc, one for each staff. MyScore.ly will contain the commands that combine these staff files into a full ensemble score. Double click MyScore.ly to generate a PDF (see LilyPond docs for updates, changes, and variations).
LilyPondWriter exports a JMSL Score to LilyPond GNU LilyPond 2.24.3 (running Guile 3.0) format. Each staff of the JMSL Score is written to its own .ly file, then combined in a full ensemble score by a master .ly file. (According to LilyPond docs, this is the recommended method for creating a full ensemble score, so parts can be transposed and printed separately). So if your LilyPond filename is MyScore.ly, then LilyPondWriter will generate MyScoreStaffAA.ly, MyScoreStaffAB.ly, MyScoreStaffAC.ly, etc, one for each staff. MyScore.ly will contain the commands that combine these staff files into a full ensemble score. Double click MyScore.ly to generate a PDF (see LilyPond docs for updates, changes, and variations).
Usage:
File lilyPondFile = new File("MyScore.ly"); try { LilyPondWriter lilyPondWriter = new LilyPondWriter(score, lilyPondFile); lilyPondWriter.write(); if (lilyPondWriter.durationErrorsInScore()) { System.err.println(lilyPondWriter.getDurationErrorReport()); } } catch (IOException e) { }MOD 2015-09-14 lots of lyrics fixes.
- Author:
- Nick Didkovsky, nick@didkovsky.com
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LY_VERSION
minimum LilyPond version that this is compatible with -
Constructor Summary
Constructors Constructor Description LilyPondWriter(Score score, java.io.File file)
Write JMSL score to LilyPond file -
Method Summary
Modifier and Type Method Description boolean
durationErrorsInScore()
It is important that the input Score has correct total durations in each staff of each measure.
This is because LilyPond lays out its own barlines, so if you have 5 quarter notes in a measure of 4/4, for example, LilyPond will put the barline after the 4th note.java.lang.String
getDurationErrorReport()
It is important that the input Score has correct total durations in each staff of each measure.
This duration error report is generated by com.softsynth.jmsl.score.operators.DurationReporter on the Score that this LilyPondWriter is converting.java.lang.String
getUnbalancedRepeatsErrorReport()
LilyPond will not layout a score properly if the score has unbalanced repeat bars ||: :||static void
main(java.lang.String[] args)
Create a JMSL Score with a variety of musical test cases and write to LilyPond formatboolean
unbalancedRepeatsErrorsInScore()
LilyPond will not layout a score properly if the score has unbalanced repeat bars ||: :||void
write()
Export Score in LilyPond format.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
LY_VERSION
public static final java.lang.String LY_VERSIONminimum LilyPond version that this is compatible with- See Also:
- Constant Field Values
-
-
Constructor Details
-
LilyPondWriter
Write JMSL score to LilyPond file- Throws:
java.io.IOException
-
-
Method Details
-
write
public void write() throws java.io.IOExceptionExport Score in LilyPond format. Writes one file per staff plus a file that combines all staves into a full ensemble score.- Throws:
java.io.IOException
-
durationErrorsInScore
public boolean durationErrorsInScore()It is important that the input Score has correct total durations in each staff of each measure.
This is because LilyPond lays out its own barlines, so if you have 5 quarter notes in a measure of 4/4, for example, LilyPond will put the barline after the 4th note. If you have too few durations, you will see barlines after the next measure's contents.- Returns:
- true if some measures in JMSL Score contain total durations that are higher or lower than what is expected by time signature. false if your input score is OK
- See Also:
getDurationErrorReport()
-
getDurationErrorReport
public java.lang.String getDurationErrorReport()It is important that the input Score has correct total durations in each staff of each measure.
This duration error report is generated by com.softsynth.jmsl.score.operators.DurationReporter on the Score that this LilyPondWriter is converting.- Returns:
- report of which measures and which staves in JMSL Score contained too few or too many durations. Measure 1 is first measure. Staff 1 is top staff.
-
unbalancedRepeatsErrorsInScore
public boolean unbalancedRepeatsErrorsInScore()LilyPond will not layout a score properly if the score has unbalanced repeat bars ||: :|| -
getUnbalancedRepeatsErrorReport
public java.lang.String getUnbalancedRepeatsErrorReport()LilyPond will not layout a score properly if the score has unbalanced repeat bars ||: :|| -
main
public static void main(java.lang.String[] args)Create a JMSL Score with a variety of musical test cases and write to LilyPond format
-