On 2020-04-14 9:14 am, Benjamin Bloomfield wrote:
However, I am still trying to figure out how engravers and contexts
work to
be able to know exactly what's going on.
Thanks for any help or ideas,
Here is my take that works from events not grobs, plus it allows
flexibility in what you want to do between words:
%%%%
\version "2.20.0"
modifyContextPropertyWhereDefined =
#(define-scheme-function
(prop value-or-proc) (symbol? scheme?)
(lambda (context)
(ly:context-set-property!
(ly:context-property-where-defined context prop)
prop
(if (procedure? value-or-proc)
(value-or-proc (ly:context-property context prop))
value-or-proc))))
incrementBarNumber =
\modifyContextPropertyWhereDefined
internalBarNumber #1+
insertBar =
\modifyContextPropertyWhereDefined
whichBar \etc
betweenLyrics = #(define-scheme-function
(proc) (procedure?)
(lambda (context)
(let ((first-lyric? #t) (hyphen? #f))
(make-engraver
(listeners
((hyphen-event engraver event) (set! hyphen? #t))
((lyric-event engraver event)
(if first-lyric?
(set! first-lyric? #f)
(if (not hyphen?) (proc context)))
(set! hyphen? #f)))))))
doBoth = #(define-scheme-function
(proc1 proc2) (procedure? procedure?)
(lambda args (apply proc1 args) (apply proc2 args)))
repetitions = #3
notes = \repeat unfold \repetitions {
fis'4 4 4 4 4 4 4( 4) 4( 4 4) 4 4 }
words = \repeat unfold \repetitions \lyricmode {
a b -- b c -- c -- c d e -- e f }
<< \new Staff { \cadenzaOn \new Voice = melody \notes }
\new Lyrics \with {
\consists \betweenLyrics \incrementBarNumber
} \lyricsto melody \words >>
<< \new Staff { \cadenzaOn \new Voice = melody \notes }
\new Lyrics \with {
\consists \betweenLyrics \insertBar "'"
} \lyricsto melody \words >>
<< \new Staff { \cadenzaOn \new Voice = melody \notes }
\new Lyrics \with {
\consists \betweenLyrics \doBoth \insertBar "" \incrementBarNumber
} \lyricsto melody \words >>
%%%%
-- Aaron Hill