Class Cwn_to_lilypond

java.lang.Object
eu.bandm.music.top.Cwn_to_lilypond

public class Cwn_to_lilypond extends Object
Creates a simple lilypond output for one or more Score_cwn object/s. These are combined in one ".ly" file, in different "score{..}" blocks.
  • Field Details

    • timeless_includefile

      public static final String timeless_includefile
      Timeless parameter for selecting the major include file. NOT YET OPERATIVE.
      See Also:
    • timeless_language

      public static final String timeless_language
      Timeless parameter for selecting the source text language. NOT YET OPERATIVE.
      See Also:
    • timeless_shareStaff

      public static final String timeless_shareStaff
      Timeless parameter for an automated sharing of staffs by voices.
      See Also:
    • msg

      protected final MessageReceiver<SimpleMessage<?>> msg
      Evident
    • scores

      protected final List<Score_cwn> scores
      All scores which shall be printed by this instance. All data goes together into one single disk-file, but with a new lilypond "score{}" block for each.
    • score

      protected Score_cwn score
      The currently processed score input.
    • parameters_beams

      protected final MTree.CheckedParameters parameters_beams
      Parameter collection controlling metric split beams. Configuration parameter, set once when constructing.
    • parameters_approximate

      @Opt protected final MCover.CheckedParameters_approximate parameters_approximate
      Parameter collection controlling metric split approximation by binary division. Iff == null, the binary division will not be applied. Configuration parameter, set once when constructing.
    • parameters_divide

      @Opt protected final MCover.CheckedParameters_divide parameters_divide
      Parameter collection controlling metric split approximation by synthesis of new divisions. Iff == null, this method will not be applied. Configuration parameter, set once when constructing.
    • parameters_splitter

      protected final MSplitter.CheckedParameters parameters_splitter
      Parameter collection controlling metric split dotting, sibling merge, syncopes, etc. Configuration parameter, set once when constructing.
    • wholeMeasurePauses

      protected final boolean wholeMeasurePauses
      Whether a pause covering a whole measure shall be printed in a special way, namely always with the duration "1/1" and in the geometric middle between the bars. Configuration parameter, set once when constructing.
    • default_includefile

      public static final String default_includefile
      Name of the lilypond include file for language selection. Must be in sync with default_language.
      See Also:
    • default_language

      public static final String default_language
      Default language to use for pitch class names etc. Must be in sync with default_includefile.
      See Also:
    • includefile

      protected String includefile
      Name of the lilypond include file for language selection. Default can be overrriden in the timeless prefix of the tscore by timeless_includefile. Must be in sync with language.
    • language

      protected String language
      Language to use for pitch class names etc. Default can be overrriden in the timeless prefix of the tscore by timeless_language. Must be in sync with includefile.
    • metricSplitters

      protected final Map<MTreeSpec,MSplitter> metricSplitters
      Local cache of one metric splitter each (with its internal cache) per metric tree specifications.
    • transpositions

      protected Map<Vox,FunctionalInterval> transpositions
      Maps of transpostions to be applied to the score data before writing out. The Score_cwn data will be transposed by this interval upward before translating it into lilypond source text. Can be set by putTransposition(Vox,FunctionalInterval).
    • voicesShareStaff

      protected boolean voicesShareStaff
      Whether more than one voice is in the same staff. If true, then the starting points of the staffs are indicated by firstLabels / shortLabels defined for each for the first voice, in their order of the call to convertVoices(java.lang.String,eu.bandm.tscore.model.Part,java.util.List<eu.bandm.tscore.model.Vox>).
    • firstLabels

      protected Map<Vox,String> firstLabels
      Maps of the labels which shall be printed before the very first staff for this voice. Must be set by putLabels(Vox,String,String).
    • shortLabels

      protected Map<Vox,String> shortLabels
      Maps of the labels which shall be printed before the subsequent (non-first) staves for this voice. Must be set by putLabels(Vox,String,String).
    • relativeScoreSize

      protected int relativeScoreSize
      Whether the sizes of notes and staves shall be altered. (Currently only 0 and -1 are supported.)
    • const_paper

      @Opt protected @Opt String const_paper
      An additional lilypond "layout{...}" text block entered into the generated source format. Can be set by set_const_paper(String).
    • const_layout

      @Opt protected @Opt String const_layout
      An additional lilypond "paper{...}" text block entered into the generated source format. Can be set by set_const_paper(String).
    • numericTimeSignature

      protected boolean numericTimeSignature
      Whether "4/4" shall be printed instead of "C", etc. Is set by set_meter_names(boolean,boolean,boolean).
    • compoundMeter

      protected boolean compoundMeter
      Whether for "irregular" meters not only the overall duration shall be printed, but the first generation child nodes, as in "3/8+2/8" instead of simply "5/8". Is set by set_meter_names(boolean,boolean,boolean).
    • shareDenominator

      protected boolean shareDenominator
      Whether compound meters shall be printed with a common denominator. E.g. "3+2/8" instead of "3/8+2/8". Is set by set_meter_names(boolean,boolean,boolean).
    • lily_generation_comment

      public static final String lily_generation_comment
      Template for the generation comment added into the generated source file format.
      See Also:
    • lily_header

      public static final String lily_header
      Template for the global include command added into the generated source file format.
      See Also:
    • lilypond_comment_leadin

      public static final String lilypond_comment_leadin
      Evident.
      See Also:
    • format_lilypond_tie

      public static final Format format_lilypond_tie
      Evident.
    • format_lilypond_pause

      public static final Format format_lilypond_pause
      Evident.
    • format_lilypond_suppress

      public static final Format format_lilypond_suppress
      Evident.
    • format_lilypond_measure_pause

      public static final Format format_lilypond_measure_pause
      Evident.
    • format_lilypond_cautionary

      public static final Format format_lilypond_cautionary
      Evident.
    • format_lilypond_forceAccidental

      public static final Format format_lilypond_forceAccidental
      Evident.
    • format_lilypond_setMetrum

      public static final Format format_lilypond_setMetrum
      Evident.
    • suppress

      boolean suppress
      Whether shan one voice share the current staff and the current voice is silent.
    • voiceNameDecompose

      public static final Pattern voiceNameDecompose
  • Constructor Details

    • Cwn_to_lilypond

      public Cwn_to_lilypond(MessageReceiver<SimpleMessage<?>> msg, List<Score_cwn> scores, @Opt MTree.CheckedParameters parameters_beams, @Opt MCover.CheckedParameters_approximate parameters_approximate, @Opt MCover.CheckedParameters_divide parameters_divide, @Opt MSplitter.CheckedParameters parameters_splitter, boolean wholeMeasurePauses)
      Only constructor. Gets the final values of many configuration parameters and all scores which shall be translated. Usage: construct an instance and then call convertVoices(String) or sim.
      Parameters:
      msg - receiver for all errors and warnings
      scores - all scores to be put into one lilypond source output file
      parameters_beams - control generation of beaming
      parameters_approximate - alternative to parameters_divide
      parameters_divide - how to synthesize required and unforseseen sub-divisions
      parameters_splitter - how to join siblings and nephews, etc.
      wholeMeasurePauses - whehter to treat them differently (1/1 durations and centraleizd)
  • Method Details

    • getMetricSplitter

      protected MSplitter getMetricSplitter(MTreeSpec mt)
      Get a metric splitter (with its internal cache) for the given metric tree specifications, or construct a new one.
    • putTransposition

      public Cwn_to_lilypond putTransposition(Vox voice, FunctionalInterval ival)
      Set a transposition to be applied to the voice before generating the lilypond source. The Score_cwn data will be transposed by this interval upward before translating it into lilypond source text.
    • putLabels

      public Cwn_to_lilypond putLabels(Vox voice, String firstLabel, String shortLabel)
      Set the initial=long and subsequent=short labels to be printed before the staff of a voice.
    • set_const_paper

      public Cwn_to_lilypond set_const_paper(String s)
    • set_const_layout

      public Cwn_to_lilypond set_const_layout(String s)
    • set_meter_names

      public Cwn_to_lilypond set_meter_names(boolean numericTimeSignature, boolean compoundMeter, boolean shareDenominator)
      Sets parameters how to render meter names. See numericTimeSignature, compoundMeter, and shareDenominator.
    • toLilyPond_duration

      public static String toLilyPond_duration(RationalDuration.DottedBaseDuration db)
      Translate duration information into lilypond format. (Apply this only after all containing brackets have been generated and their factor thus removed from the duration argument.) Works for all Rationals which have a power-of-two denominator and are e-writeable. Possibly DISLOC to "RationalDuration.lilypondString()" ?? FIXME
    • toLilyPond_pitch

      public static String toLilyPond_pitch(PitchAndOctave<OctaveRegister,FunctionalPitchModOctave> ap)
      Translate pitch information into lilypond format. Lilypond syntax for a single pitch event is :
          pitchClass Octave Accidental  Duration
        
    • formatValueOf

      public static Format formatValueOf(Rational rat)
      Translate the rational value into a literal format.
    • meterName

      public static String meterName(MTree_<?> meter, boolean useCompoundFormat, boolean compress)
      Generate a meter name based only on duration, or on an "addition" of the first generation child nodes.

      FIXME CHECK whether lilypond copes with "6/6" etc. !?!?!

      FIXME GEHEN NICHT ALLE siehe sig/examples/msplit/nichtUebersetzbar.ly !!!

      Parameters:
      compress - whether to put on ONE fractional line: "1+2+3/8" instead of "1/8+2/8+3/8".
    • toLilyPond_metrics

      public void toLilyPond_metrics(List<Format> formats, BigDecimal barnum)
      Generate a format for the start text for the measure with the given barnum, indicating its meter, (and its duration, if it is partial). Do this only if these values change w.r.t. its predecessor. Currently: encode metrics only as a measure DURATION, no influence on beams and grouping, etc. MISSING FIXME
      Parameters:
      formats - where to append the generated command
    • transpose

      Deliver the pitch transposed UP by the interval which is assigned to the voice in transpositions, if any.
    • transpose

      Deliver the pitch transposed UP by the interval which is assigned to the voice in transpositions, if any.
    • toLilyPond_key

      public void toLilyPond_key(List<Format> formats, Event event)
      Emit a lilypond diatonic key change, if the Event carries such a command. No voice is defined so not transposition is applied.
      Parameters:
      formats - where to append the generated command
    • toLilyPond_key

      protected void toLilyPond_key(@Opt @Opt Vox voice, List<Format> formats, Event event)
      Emit a lilypond diatonic key change, if the Event carries such a command. Transposition according to transpositions is applied.
      Parameters:
      formats - where to append the generated command
    • toLilyPond_clefSelect

      public void toLilyPond_clefSelect(List<Format> formats, Event event)
      Generate a format for changing the clef, iff event carries such a command.
      Parameters:
      formats - where to append the generated command
    • toLilyPond_clefSelect

      public void toLilyPond_clefSelect(List<Format> formats, Event event, ClefUsage cu)
      Generate a format for changing the clef.
      Parameters:
      formats - where output is appended.
    • barnum2format

      public static Format barnum2format(BigDecimal barnum)
      Generate a lilypond comment format indicating the bar number / measure number.
    • convertOneVoice

      public Format convertOneVoice(Vox voice, boolean includeMetric, @Opt @Opt List<Format> formatsLyrics)
      Generate a format for one particular voice (possibly including metric info) which can be read by LilyPond. Assume all input data (semantic maps in Score_cwn) are valid. Esp. it requires ...
      • that the metric voice has a metric indication at the very first timepoint,
      • + that all voices start at the first TopTp
      • that the very first event in every voice carries a clef selection
      Parameters:
      voice - to convert
      includeMetric - In lilypond, changes of metrum and duration of all measures are global and valid for all voices simultaneously. They thus need to appear only in one voice. This parameter says whether metrum information shall be included in the currently generated lilypond voice.
      formatsLyrics - output parameter where to put the formats realizing the sung text. If ==null, no lyric formats are generated. (FIXME: currently ONE STANZA only?!?!!)
    • convertVoices

      public Format convertVoices(String sourcename, Part part, List<Vox> voices)
      Generate a format representing Lilypond source text, for one tscore source "PART" and the given list of voices. A null in global data shortLabels means that voice shares the staff with its predecessor.
      Parameters:
      sourcename - only for doc comments about the generation.
      part - the tscore raw parsing level Part object (indicating all voices, timeless parameters, etc.)
      voices - to convert
    • convertVoices

      public Format convertVoices(String sourcename)
      Generate the format of a lilypond source file, for all Score_cwn instances in scores. Each such will be put into one lilypond "Score{..}" block.
      Parameters:
      sourcename - only for doc comments about the generation.
    • staffsByVoiceNames

      public static Map<Vox,String> staffsByVoiceNames(List<Vox> voices, int maxnum)
      Constructs a list of staff names for a list of voices. Each "null" in the list indicates the voice belonging to its predecessors. For instance, if maxnum=2, then the sequence of voice names
      "Hrn1", "Hrn3", "Hrn2", "Hrn4", "Hrn5", "Trp" will result into
      "Hrn1,2", null, "Hrn2,4", null, "Hrn5" "Trp".
      With maxnum=3 we get
      "Hrn1,3,2", null, null, "Hrn4,5", null, "Trp".

      This data is intended to be fed into firstLabels and shortLabels in case thate voicesShareStaff ==true.

    • main

      public static void main(String[] args)
      Stand-alone application, translates input file "arg[0]" to lilypond output file "arg[1]".