3

Is there a way to align lyrics in LilyPond in such a way that the syllable vowel (or last vowel of a diphtong) aligns to the note (or the first note of a melisma), like we find in gregorian chant scores?

[UPDATE] More specifically, given LSR 888, how could I improve it to get a center-on-vowel behaviour, similar to center-on-word of the current snippet implementation?

2 Answers 2

2

I was able to modify LSR 888 snippet to provide a center-on-vowel logic, as follows:

% Based on https://lsr.di.unimi.it/LSR/Item?id=888
#(define vowel-set
  (list->char-set
    (string->list "AÁÀÃÂÆǼEÉÈÊIÍÌÎOÓÒÕÔŒUÚÙÛaáàãâæǽeéèêiíìîoóòõôœuúùû")))

#(define (width grob text)
  (let* ((X-extent
           (ly:stencil-extent (grob-interpret-markup grob text) X)))
   (if (interval-empty? X-extent)
       0
       (cdr X-extent))))

#(define (center-on-vowel grob)
  (let* ((text (ly:grob-property-data grob 'text))
         (syllable (markup->string text))
         (word-position
           (if (string-index syllable vowel-set)
               (string-index syllable vowel-set)
               0))
         (word-end
           (if (string-index-right syllable vowel-set)
               (1+ (string-index-right syllable vowel-set))
               (string-length syllable)))
         (preword (substring syllable 0 word-position))
         (word (substring syllable word-position word-end))
         (preword-width (width grob preword))
         (word-width (width grob (if (string-null? syllable) text word)))
         (note-column (ly:grob-parent grob X))
         (note-column-extent (ly:grob-extent note-column note-column X))
         (note-column-width (interval-length note-column-extent)))

  (-
    (*
      (/ (- note-column-width word-width) 2)
      (1+ (ly:grob-property-data grob 'self-alignment-X)))
    preword-width)))

And then I can use it in my project with something like this:

\layout {
  \context {
    \GregorianTranscriptionLyrics {
      \override LyricText.X-offset = #center-on-vowel
    }
  }
}
1

You could simply align the Lyrics like this:

{
  4 4 4 4
} \addlyrics {
  test test
  \override LyricText.self-alignment-X = #-0.25
  \override LyricText.parent-alignment-X = #CENTER
  test test
}

Theoretically one could automatically derive the value from the text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.