[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \displayLilyMusic
From: |
Nicolas Sceaux |
Subject: |
Re: \displayLilyMusic |
Date: |
Sun, 22 May 2005 19:24:11 +0200 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Han-Wen Nienhuys <address@hidden> writes:
> Nicolas Sceaux wrote:
>> I have an nearly complete implementation of a \displayLilyMusic
>> command.
>> \displayLilyMusic \new Voice { \clef alto \time 3/4 \key g
>> \minor c'2. |
>> \once \override TextScript #'padding = #2
>> d'2 e'4^\markup { \bold { hello \italic world ! } }
>> }
>> ==>
>> \new Voice {
>> \clef "alto"
>> \time 3/4
>> \key g \minor
>> c'2. |
>> \once \override TextScript #'padding = #2
>> d'2 e'4^\markup \line { \bold "hello" \bold \italic "world" \bold
>> "!"} }
>> \displayLilyMusic \transpose c' a { <c e> <d f> }
>> ==>
>> { < a, cis > < b, d > }
>> Should there be such a command inside the LilyPond distribution?
>
> it would be wonderful to have it. My only reservation is
> maintainability. How sensitive is this to breakage when we change the
> music implementation (property names, etc?)
This is indeed a major concern. Of course, the print method for a
music type will stop working if the relevant property names are changed.
Here is an example of such a method:
(define-primary-print-method TimeScaledMusic (times)
(parameterize ((*force-line-break* #f)
(*time-factor-numerator* (ly:music-property times 'numerator))
(*time-factor-denominator* (ly:music-property times
'denominator)))
(format #f "\\times ~a/~a ~a"
(*time-factor-numerator*)
(*time-factor-denominator*)
(print-lily-music (ly:music-property times 'element)))))
in this case, if numerator and denominator names change, it will print
something like:
\times ()/() { ... }
Or if it is the element property that changes, it will print:
\times 3/4 %{ expecting a music expression: () %}
If a print method is not implemented for some music type:
%{ Print method not implemented for music type StrangeEvent %}
When I have finished implementing methods for the remaining music
types, I'll send here the code. (I've just seen some improvements to
do also).
;;BusyPlayingEvent
;;ClusterNoteEvent
;;FoldedRepeatedMusic
;;LyricCombineMusic
;;MelismaPlayingEvent
;;MultiMeasureTextEvent
;;NewLyricCombineMusic
;;NoteGroupingEvent
;;OutputPropertySetMusic
;;PartCombineMusic
;;PesOrFlexaEvent
;;QuoteMusic
;;ScriptEvent
;;SoloOneEvent
;;SoloTwoEvent
;;StartPlayingEvent
;;UnaCordaEvent
;;UnisonoEvent
;;UnrelativableMusic
;;UntransposableMusic
A music pattern matcher was defined for recognizing some more complex
expressions, eg:
(add-print-method ContextSpeccedMusic (expr)
"If `expr' is a bar, return \"\\bar ...\".
Otherwise, return #f."
(with-music-match (expr (music
'ContextSpeccedMusic
element (music
'ContextSpeccedMusic
context-type 'Timing
element (music
'PropertySet
value ?bar-type
symbol 'whichBar))))
(format #f "\\bar \"~a\"~a" ?bar-type (print-lily-new-line))))
Here, if the implementation of bars changes somewhat, the default
methods for contexts and property sets will be called.
\context Score \set Timing . whichBar = #"||"
nicolas