lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resetting accidentals at word breaks


From: Benjamin Bloomfield
Subject: Re: resetting accidentals at word breaks
Date: Wed, 15 Apr 2020 09:18:42 -0400

Thanks, this works beautifully, and insertBar also solves a problem that I had of needing to put empty bars in between syllables to allow line breaks there, which I had previously been solving by preprocessing the lyrics to add \bar "" in between all the lyric syllables.

Thanks so much!

Now I need to figure out automatically adding cautionary accidentals the first time the pitch appears after the accidental has been reset.  I've been having trouble finding documentation on defining new accidental Styles, but I will continue looking a bit before turning to the forum for more help.

Benjamin Bloomfield

On Tue, Apr 14, 2020 at 3:02 PM Aaron Hill <address@hidden> wrote:
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]