lilypond-user
[Top][All Lists]
Advanced

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

Re: Lyrics - align first wowel of a syllable under the notehead -- SUCCE


From: Jiri Zurek (Prague)
Subject: Re: Lyrics - align first wowel of a syllable under the notehead -- SUCCESS
Date: Tue, 3 Feb 2009 03:05:18 -0800 (PST)

Dear Carl,
your work is indeed very good and vowel aligned syllables work for most
time. However, there is still need for a small impromevement. The vowel
centered alignment works on single notes and even it works on beamed notes
and or melismata if they are declared with \melisma \melismaEnd functions.
However, as soon as a slur is attached to the notehead, the vowel centering
does not work and the vowel is hard-left aligned. I know that this is
regularly so in Lilypond (although it is not consistent since the hard-left
alignment - declared to improve the legibility of melismata - works only on
slured notes and not on unslured melismata, but this does not bother me as I
do not want the left or center aligning at all). Can this be solved, please?
I know there was a function lyricMelismaAlignment which solves the hard-left
aligning of syllables and it could perhaps give you the clue what else must
be changed in order that the vowel centering works also on slured notes.
Otherwise, your work is indeed very eminent. 
Thank you.

I changed a bit you example, to show the behavior on slurred notes,
melismata, beamed notes and single notes. The first line of lyrics is
default aligned, the second line is supposed to be vowel centered:

\version "2.12"

\paper { ragged-right = ##t }

#(define vowel-set (list->char-set (string->list "AEIOUaeiou")))
#(define secondary-vowel-set (list->char-set (string->list "Yy")))

#(define (vowel-alignment syllable)
    "Calculate the alignment of a syllable in order to place the
    first vowel at the notehead."
    (let* ((syllable-length (string-length syllable))
           (vowel-count (string-count syllable vowel-set))
           (vowel-position (string-index syllable vowel-set))
           (secondary-vowel-count (string-count syllable
secondary-vowel-set))
           (secondary-vowel-position
            (string-index syllable secondary-vowel-set))
           (align-character
            (if (> vowel-count 0)
                vowel-position
                (if (> secondary-vowel-count 0)
                    secondary-vowel-position
                    (/ syllable-length 2)))))
     (- 
      (/ 
       (* 2 (+ align-character 0.5))     ; 2 is for RIGHT-LEFT
                                        ; 0.5 is to center on vowel
       syllable-length)
      1)))


#(define (vowel-center music)
  "For every EventChord in elements of @var{music}, if elements in
EventChord has a LyricEvent, add an item just before the EventChord
that will provide the appropriate self-alignment-X to allow vowel-centered
lyrics."
  (define (insert-X-align element-list)
     (if (null? element-list)
         '()
         (let* ((element (car element-list))
                (element-name (ly:music-property element 'name))
                (syllable (if (eq? element-name 'EventChord)
                           (let ((sub-element
                                  (car
                                    (ly:music-property element 'elements))))
                            (if (eq? (ly:music-property
                                      sub-element
                                      'name
                                      'LyricEvent))
                                (ly:music-property sub-element 'text)
                                #f))
                            #f)))
             (if syllable
              (cons
                (make-music
                 'ContextSpeccedMusic
                 'context-type 'Bottom
                 'element
                 (make-music
                  'OverrideProperty
                  'pop-first #t
                  'grob-property-path '(self-alignment-X)
                  'grob-value (vowel-alignment syllable)
                  'once #t
                  'symbol 'LyricText))
              ;"INSERTED HERE"
              (cons
               element
               (insert-X-align (cdr element-list))))
             (cons element (insert-X-align (cdr element-list)))))))
          

  (set! (ly:music-property music 'elements)
        (insert-X-align (ly:music-property music 'elements)))
  music)

vowelAlignedLyrics  = #(define-music-function (parser location music)
(ly:music?)
   "Set x alignment so each syllable of @var{music} will be
aligned with the first vowel centered on the note."
   (vowel-center music))
  
theNotes = \relative c''
{
  g8( c) b( a) b \melisma g \melismaEnd f( e) | c \melisma d \melismaEnd c(
e) a16 [ \melisma g f  e ] \melismaEnd  fis8 a | g1
}
theLyrics = \lyricmode {
  Each ssyl -- lla -- ble's vowel is unnn -- der the note.
}

\score
{
  <<
    \new Voice = "melody" \theNotes
    \new Lyrics \lyricsto "melody" \theLyrics
    \new Lyrics \lyricsto "melody" \vowelAlignedLyrics \theLyrics
  >>
}




Carl D. Sorensen wrote:
> 
> Success!  It's not perfect, because it doesn't recognize that we're using
> a
> proportional font, but it looks pretty good to me.
> 
> It uses vowels (characters that are always vowels) and secondary vowels
> (characters that are vowels only if there isn't a regular vowel, like y in
> english), both of which are easily user=defined.
> 
> I hope this helps.  It seems to me to work pretty well.
> 
> Carl
> 
> 
http://www.nabble.com/file/p21807742/sylAlign.png 
-- 
View this message in context: 
http://www.nabble.com/Re%3A-Lyrics---align-first-wowel-of-a-syllable-under-the-notehead----SUCCESS-tp21720060p21807742.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.





reply via email to

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