On 2016-12-12 13:48, Knut Petersen wrote:
Hi everybody!Please test and comment, patch and examples attached.
Hi Knut,works beautifully, as far as your code is concerned. But I found a bug in my function (add-lyric-extenders): Unintuitively, adding an extender after _ makes extenders disappear: compare { Foo __ _ } against { Foo __ _ __ }.
The fixed function is in your regtest, along with a testcase for it. Cheers, Alexander
\version "2.19.53" \paper { ragged-right = ##f } \pointAndClickOff #(set-global-staff-size 16) #(define (has-hyphen? event) (let* ((art (ly:music-property event 'articulations)) (is-hyphen? (lambda (ev) (eq? (ly:music-property ev 'name) 'HyphenEvent)))) (find is-hyphen? art))) #(define (add-extender! event) (ly:music-set-property! event 'articulations (append (ly:music-property event 'articulations) (list (make-music (quote ExtenderEvent))))) event) add-lyric-extenders = #(define-music-function (parser location lyrics) (ly:music?) (music-map (lambda (event) (if (and (eq? (ly:music-property event 'name) 'LyricEvent) ; do not add extenders below hyphens (not (has-hyphen? event)) ; do not add additional extenders after _ (internally equivalent to " ") ; to avoid killed extenders (not (string=? (ly:music-property event 'text) " "))) (add-extender! event)) event) lyrics)) \markup { "no extenders"} << { c''2. 4 ~ 4 2. ~ 2. 4 ~ \break 2. 4 2 ~ 2 \bar "|." } \addlyrics { foo -- bar foo -- bar foo -- bar } >> \markup { "automatic extenders"} << { c''2. 4 ~ 4 2. ~ 2. 4 ~ \break 2. 4 2 ~ 2 \bar "|." } \addlyrics { \add-lyric-extenders \repeat unfold 3 { foo -- bar }} >> << { c''2. 4 ~ 4 2. ~ 2. 4 ~ \break 2. 4 1 \bar "|." } \addlyrics { \add-lyric-extenders \repeat unfold 3 { foo -- bar }} >> \markup { "automatic extenders, extender on last note forced"} << { c''2. 4 ~ 4 2. ~ 2. 4 ~ \break 2. 4 1 \bar "|." } \addlyrics { \add-lyric-extenders { foo -- bar foo -- bar foo -- \override Lyrics.LyricExtender.minimum-length = #30 \override Lyrics.LyricExtender.force-extender = ##t bar }} >> \markup { "automatic extenders, minimum-length 8 "} << { c''1 2 ~ 2 2 4 ~ 4 4 8 ~ 8 8 16 ~ 16 4 1 \bar "|." } \addlyrics { \add-lyric-extenders { \override Lyrics.LyricExtender.minimum-length = #8 \repeat unfold 10 { foo -- bar }}} >> \markup { "automatic extenders, minimum-length 4 "} << { c''1 2 ~ 2 2 4 ~ 4 4 8 ~ 8 8 16 ~ 16 4 1 \bar "|." } \addlyrics { \add-lyric-extenders { \override Lyrics.LyricExtender.minimum-length = #4 \repeat unfold 10 { foo -- bar }}} >> \markup { "automatic extenders, minimum-length 2 "} << { c''1 2 ~ 2 2 4 ~ 4 4 8 ~ 8 8 16 ~ 16 4 1 \bar "|." } \addlyrics { \add-lyric-extenders { \override Lyrics.LyricExtender.minimum-length = #2 \repeat unfold 10 { foo -- bar }}} >> \markup { "automatic extenders, minimum-length 1 "} << { c''1 2 ~ 2 2 4 ~ 4 4 8 ~ 8 8 16 ~ 16 4 1 \bar "|." } \addlyrics { \add-lyric-extenders { \override Lyrics.LyricExtender.minimum-length = #1 \repeat unfold 10 { foo -- bar }}} >> \markup { "automatic extenders, mixed manual and automatic melismata, extender on last note forced "} << { \autoBeamOff c''2 2 4\( 4 4 4\) 4 4 4\( 4( 4) 8[ 8] 8\) 16\(\melisma 16\melismaEnd 4\) 1 \bar "|." } \addlyrics { \add-lyric-extenders { \override Lyrics.LyricExtender.minimum-length = #8 \repeat unfold 2 { foo -- _ bar _ _ _ } foo -- _ \override Lyrics.LyricExtender.force-extender = ##t bar _ _ _ } } >> \layout {}
lyrextest.pdf
Description: Adobe PDF document
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user