Hello list,
I would like to have somthing like
\version "2.19.22"
{
\time 3/4
% bar 1
c'2.
\skipUntil #5 % s2.*4
% bar 5
c'2.
\restUntil #8 % R2.*2
% bar 8
c'2.
}
so I don’t have to count bars every time an instrument has a long rest
(could also be helpful when composing, or, in a more advanced version,
when skipping several bars with many time signature changes).
My first thought was “I need a music function that accesses
currentBarNumber” but that (and, for the more advanced version,
measureLength) is a context property. Now I don’t know how to get the
context to this music function and making it return a (make-music
'MultiMeasureRestMusic …). Attached is my first attempt but that returns
only (make-music 'ApplyContext …).
Is this the correct approach? Or do I have to write an engraver? If so,
where can I learn how to do that?
Thanks in advance,
Malte
\version "2.19.22"
restUntil =
#(define-music-function (targetBar) (integer?)
#{
\applyContext
#(lambda (context)
(let* ((currentBar (ly:context-property context 'currentBarNumber))
(currentMeasureLength (ly:moment-main (ly:context-property context 'measureLength)))
(difference (- targetBar currentBar))
(product (* currentMeasureLength difference)))
(make-music
'MultiMeasureRestMusic
'duration
(ly:make-duration 0 0 product))))
#})
{
\time 3/4
% bar 1
c'2.
\displayMusic \restUntil #5
% shold be bar 5
c'2.
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user