lilypond-user
[Top][All Lists]
Advanced

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

Re: Manipulating lyrics with a music function


From: Jean Abou Samra
Subject: Re: Manipulating lyrics with a music function
Date: Tue, 12 Oct 2021 20:21:07 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Le 09/10/2021 à 21:47, David F. a écrit :
I did notice that the \markup defeats lyric ties.

You can special-case bare strings to return a string:

\version "2.22.1"

openQuote =
#(define-scheme-function (text) (markup?)
   (if (string? text)
       (string-append "“" text)
       #{ \markup \concat { “ #text } #}))

closeQuote =
#(define-scheme-function (text) (markup?)
   (if (string? text)
       (string-append text "”" text)
       #{ \markup \concat { #text ” } #}))

\relative { \time 3/4 e'4 e4. e8 d4 e d c2. }
\addlyrics { \openQuote O~In -- com -- pa --  ra -- \closeQuote ble, said she }


It’s not a big deal—that combo only occurs once in the songs I have.  But now 
I’m curious.  What do lyric syllables get turned into?  A LyricEvent?  Is it 
possible to build and return a LyricEvent from a function?

Yes. Add \displayMusic before any music to see
how it could be built in Scheme. The code might
look like

openQuote =
#(define-music-function (lyric-event) (ly:music?)
   (display-scheme-music lyric-event)
   (make-music 'LyricEvent
               lyric-event
               'text
               (let ((text (ly:music-property lyric-event 'text)))
                 (if (string? text)
                     (string-append "“" text)
                     #{ \markup \concat { “ #text } #}))))

The following pages contain some explanations that
may be useful:

https://lilypond.org/doc/v2.22/Documentation/extending/building-complicated-functions
https://extending-lilypond.readthedocs.io/en/latest/music.html#constructing-music-from-scratch

Best,
Jean



reply via email to

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