2009/6/16 Reinhold Kainhofer <[email protected]>:
> Okay, I'm now trying to achieve this with tweaks (because they can be
> incorporated into the actual start command for the spanner, so one doesn't
> have to add one command before the note plus the start of the trill spanner
> after the note). However, how can I change the bound-details -> left -> text
> using \tweak??? All I seem to be able is to set bound-details, but not the
> subproperties... How can I tweak only the text, but leave the other settings
> in bound-details at their current values?
You could get the default bound-details from all-grob-descriptions:
#(define startSharpTrillSpan
(let* ((m (make-music 'TrillSpanEvent
'span-direction START))
(details (assoc-get 'bound-details
(assoc-get 'TrillSpanner
all-grob-descriptions)))
(left-details (assoc-get 'left details)))
(set! (ly:music-property m 'tweaks)
(acons 'extra-offset '(0 . -0.5)
(acons 'bound-details
(acons 'left
(acons 'text
(make-translate-scaled-markup
'(0.0 . -1.0)
(make-pitchedtexttrill-markup SHARP))
left-details)
details)
(ly:music-property m 'tweaks))))
m))
>
> Attached are my current attempts at creating a general function for pitched
> trills (articulations as well as spanners). While articulations seem to work
> okay (using the text-interface::print function and the trill with the
> accidental as text), I'm unable to assign the proper spanner text using a
> tweak. Does anyone have any pointers how to solve this?
(acons 'stencil (lambda (grob) (grob-interpret-markup grob
(make-pitchedtexttrill-markup alter)))
This is also more idiomatic for the music function, since Script and
TrillSpanner don't support text-interface (it also prevents annoying
warnings in the docs).
Regards,
Neil
\version "2.13.2"
#(define-markup-command (pitchedtexttrill layout props alter) (number?)
(interpret-markup layout props
(markup #:lower 1
;#:halign -1.4
#:musicglyph "scripts.trill"
#:hspace -0.5
#:fontsize -1
#:musicglyph (assoc-get alter
standard-alteration-glyph-name-alist "" ))))
\markuplines \justified-lines {pitched trill as a simple markup}
\relative c' { c^\markup{\pitchedtexttrill #SHARP }}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flatTrillI = #(let ((m (make-music 'ArticulationEvent 'articulation-type
"trill")))
(ly:music-set-property! m 'tweaks
(acons 'stencil (lambda (grob) (grob-interpret-markup grob
(make-pitchedtexttrill-markup FLAT)))
(ly:music-property m 'tweaks)))
m)
\markuplines \justified-lines {pitched trill as an articulation with stencil
tweak (every second note)}
\relative c' {
c4\flatTrillI c-\flatTrillI c4^\flatTrillI c_\flatTrillI
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pitchedtrill = #(define-music-function (parser location alter) (number?)
(let ((m (make-music 'ArticulationEvent
'articulation-type "trill")))
(ly:music-set-property! m 'tweaks
(acons 'stencil (lambda (grob) (grob-interpret-markup grob
(make-pitchedtexttrill-markup alter)))
(ly:music-property m 'tweaks)))
m))
flatTrill = -\pitchedtrill #FLAT
sharpTrill = -\pitchedtrill #SHARP
\markuplines \justified-lines {pitched trill as an articulation with stencil
tweak as music-function}
\relative c' {
c4\pitchedtrill #FLAT c4-\pitchedtrill #FLAT c4\flatTrill c4\sharpTrill
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flatTrillI = -\tweak #'stencil #(lambda (grob) (grob-interpret-markup grob
(make-pitchedtexttrill-markup FLAT))) \trill
sharpTrillI = -\tweak #'stencil #(lambda (grob) (grob-interpret-markup grob
(make-pitchedtexttrill-markup SHARP))) \trill
\markuplines \justified-lines {Tweaking a trill stencil using a simple
definition, stencil set to (make-pitchedtexttrill-markup XXX)}
\relative c' {
c4\flatTrillI c4\sharpTrillI c4-\flatTrillI c4-\sharpTrillI
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% (stencil . ,ly:text-interface::print)
% (text . ,(make-musicglyph-markup "scripts.rcomma"))
flatTrillII = -\tweak #'stencil #ly:text-interface::print -\tweak #'text
#(make-pitchedtexttrill-markup FLAT ) \trill
sharpTrillII = -\tweak #'stencil #ly:text-interface::print -\tweak #'text
#(make-pitchedtexttrill-markup SHARP ) \trill
pitchedtrillII = #(define-music-function (parser location alter) (number?)
(let ((m (make-music 'ArticulationEvent
'articulation-type "trill")))
(ly:music-set-property! m 'tweaks
(acons 'stencil ly:text-interface::print (acons 'text
(make-pitchedtexttrill-markup alter)
(ly:music-property m 'tweaks))))
m))
\markuplines \justified-lines { The same, using the text-interface::print
stencil and the text property; Usine a music-function only works with -
prepended }
\relative c' {
c4\flatTrillII c4\sharpTrillII c4-\flatTrillII c4-\sharpTrillII
c4\pitchedtrillII #FLAT c4-\pitchedtrillII #FLAT
c4\pitchedtrillII #NATURAL c4-\pitchedtrillII #NATURAL
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\markuplines \justified-lines { Tweaking trill spanners. Default text, but
extra-offset }
\relative c' {
c4-\tweak #'extra-offset #'(2 . -5) \startTrillSpan c c c\stopTrillSpan
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% tWF = -\tweak #'bound-details #'left #'text = \markup{\pitchedtexttrill #FLAT
}
% -\tweak #'extra-offset = #'(0 . -0.5) \startTrillSpan
trillWithFlat = {
\once \override TrillSpanner #'bound-details #'left #'text =
\markup{\pitchedtexttrill #FLAT }
\once \override TrillSpanner #'extra-offset = #'(0 . -0.5)
}
trillWithNatural =
{
\once \override TrillSpanner #'bound-details #'left #'text =
\markup{\pitchedtexttrill #NATURAL }
\once \override TrillSpanner #'extra-offset = #'(0 . -0.5)
}
trillWithSharp =
{
\once \override TrillSpanner #'bound-details #'left #'text =
\markup{\pitchedtexttrill #SHARP }
\once \override TrillSpanner #'extra-offset = #'(0 . -0.5)
}
\markuplines \justified-lines { Changing text of trill spanner using
"\override" before the note, text created by "\markup{\pitchedtexttrill #XXX}" }
\relative c' {
c4\startTrillSpan c4 c4 c4\stopTrillSpan |
\trillWithFlat c4\startTrillSpan c4 c4 c4\stopTrillSpan |
\trillWithSharp c4\startTrillSpan c4 c4 c4\stopTrillSpan |
\trillWithNatural c4\startTrillSpan c4 c4 c4\stopTrillSpan |
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\markuplines \justified-lines {Trying to set the values using tweaks for the
spanner. Apparently, tweaking the bound-details -> left -> text is not so
easy!!!}
#(define startSharpTrillSpan
(let* ((m (make-music 'TrillSpanEvent
'span-direction START))
(details (assoc-get 'bound-details
(assoc-get 'TrillSpanner
all-grob-descriptions)))
(left-details (assoc-get 'left details)))
(set! (ly:music-property m 'tweaks)
(acons 'extra-offset '(0 . -0.5)
(acons 'bound-details
(acons 'left
(acons 'text
(make-translate-scaled-markup '(0.0 .
-1.0)
(make-pitchedtexttrill-markup SHARP))
left-details)
details)
(ly:music-property m 'tweaks))))
m))
startFlatTrillSpan = -\tweak #'extra-offset #'(0 . -0.5) \startTrillSpan
\relative c' {
c4\startSharpTrillSpan c4 c4 c4\stopTrillSpan |
c4\startFlatTrillSpan c4 c4 c4\stopTrillSpan |
}
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user