[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: align-on-syllable.ly and 2.19.36
From: |
Thomas Morley |
Subject: |
Re: align-on-syllable.ly and 2.19.36 |
Date: |
Mon, 21 Mar 2016 21:47:13 +0100 |
2016-03-01 0:27 GMT+01:00 Thomas Morley <address@hidden>:
> 2016-03-01 0:11 GMT+01:00 Thomas Morley <address@hidden>:
>> 2016-02-29 5:42 GMT+01:00 David Wright <address@hidden>:
>>> Hi, I think I've got the latest version of align-on-syllable.ly
>>> (3049 Dec 4 02:21) from variously
>>>
>>> https://lists.gnu.org/archive/html/lilypond-user/2015-12/msg00124.html
>>> http://comments.gmane.org/gmane.comp.gnu.lilypond.general/107425
>>> http://lsr.di.unimi.it/LSR/Snippet?id=888
>>>
>>> and it works great in 2.18.2. However, I'm having problems using it in
>>> 2.19.36. I added the following LP code involving NullVoice to the test
>>> case, which breaks it.
>>>
>>> I don't know if it's the fault of NullVoice or align-on-syllable.ly.
>>> NullVoice is rather delicate; for example, it doesn't play well with
>>> \addlyrics for no reason obvious to me.
>>>
>>> \score {
>>> \new Staff <<
>>> \new NullVoice = "nullvoice" \melody
>>> \new Voice = "voice" \melody
>>> \new Lyrics = "testI"
>>> \with { \override LyricText.X-offset = #center-on-word }
>>> \lyricsto "nullvoice" \lyr
>>> \new Lyrics = "testII"
>>> \with { \override LyricText.X-offset = #center-on-word }
>>> \lyricsto "nullvoice" \lyrA
>>> %% The control-voice omits the override
>>> \new Lyrics = "control"
>>> \lyricsto "nullvoice" \lyrControl
>>> >>
>>> \layout {
>>> \context {
>>> \Score
>>> lyricMelismaAlignment = #-0.6
>>> }
>>> }
>>> }
>>>
>>> Cheers,
>>> David.
>>>
>>> _______________________________________________
>>> lilypond-user mailing list
>>> address@hidden
>>> https://lists.gnu.org/mailman/listinfo/lilypond-user
>>>
>> Hi David,
>>
>> the problem:
>> in 2.18. the grob-parent of LyricText was NoteHead for both Voice and
>> NullVoice.
>>
>> In 2.19.37 it's NoteColumn in Voice and PaperColumn in NullVoice.
>> More, 2.19.37 returns for the LSR-code:
> should read:
> 2.19.37 returns for the LSR-code with added NullVoice:
>
>> programming error: cyclic dependency: calculation-in-progress
>> encountered for #'X-extent (PaperColumn)
>> (with a buid from master with --enable-checking)
>>
>> Right now I'm not sure how to deal with it (and when I'll have the
>> time to take a deeper look)
>>
>>
>> So far, cheers,
>> Harm
Hi,
finally I think I have a fix.
Though, in 2.19.38 there are some differences when aligning lyrics to
NullVoice compared with aligning them to Voice.
See the output of this code without any override:
\version "2.19.38"
mel = \relative c' {
c8 r
c4
<c d>
}
lyr = \lyricmode { Do Do Do }
\score {
\new Staff <<
\new Voice = "v" \mel
\new NullVoice = "nv" \mel
\new Lyrics
\with { instrumentName = "lyricsto nullv " }
\lyricsto "nv" \lyr
\new Lyrics
\with { instrumentName = "lyricsto voice " }
\lyricsto "v" \lyr
>>
\layout {
indent = 30
}
}
My proposed code for the LSR-snippet will not cure that. Would be
beyond the duty of it.
Though, please test:
\version "2.18.2" % up to 2.19.39
#(define space-set
(list->char-set
(string->list "—.?-;,:“â€â€˜â€™â€“— */()[]{}|<>!`~&…")))
#(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 (find-paper-column grob)
(cond ((not (ly:grob? grob))
(ly:error "PaperColumn is not in the parent-tree of ~a" grob))
((grob::has-interface grob 'paper-column-interface)
grob)
(else (find-paper-column (ly:grob-parent grob X)))))
#(define (center-on-word grob)
(let* ((text (ly:grob-property-data grob 'text))
(syllable (markup->string text))
(word-position
(if (string-skip syllable space-set)
(string-skip syllable space-set)
0))
(word-end
(if (string-skip-right syllable space-set)
(+ (string-skip-right syllable space-set) 1)
(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)))
(word-end-width (- word-width preword-width))
(par (ly:grob-parent grob X))
(parent (if (grob::has-interface par 'note-head-interface)
par
(find-paper-column grob)))
(note-column-extent
(cond ((grob::has-interface parent 'note-head-interface)
(ly:grob-extent parent parent X))
((grob::has-interface parent 'paper-column-interface)
(let ((nh
(filter
(lambda (g)
(grob::has-interface g 'note-head-interface))
(ly:grob-array->list
(ly:grob-object
(ly:grob-parent grob X)
'elements)))))
(ly:relative-group-extent nh (car nh) X)))
(else '(0 . 0))))
(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)))
%% For general use take this layout-setting
%% In the example below the override is applied to selected Lyrics only
%%
%\layout {
% \context {
% \Lyrics
% \override LyricText.X-offset = #center-on-word
% }
%
melody = \relative c' {
c8 r
d4 e8 r f4 |
<c d> <d c>
e( f)
g1 \bar"|."
}
lyr = \lyricmode {
\set stanza = "1. "
Do,
““Re, Mi, Fa, Do, Re,
%\once \set Score.lyricMelismaAlignment = #4.5
"...mimifa,"
\markup \bold Sol—
}
lyrA = \lyricmode {
\set stanza = "2. "
“Do
Re, Mi, Fa, Do, Re,
mimifa...
Sol!”
}
lyrControl = \lyricmode{
\set stanza = "Control: "
Do
Re Mi Fa Do Re mimifa Sol
}
\score {
\new Staff <<
\new Voice = "voice" \melody
\new Lyrics = "testI"
\with {
\override LyricText.X-offset = #center-on-word
instrumentName = "lyricsto v "
}
\lyricsto "voice" \lyr
\new Lyrics = "testII"
\with {
\override LyricText.X-offset = #center-on-word
instrumentName = "lyricsto v "
}
\lyricsto "voice" \lyrA
%% The control-voice omits the override
\new Lyrics = "control"
\with {
instrumentName = "lyricsto v "
}
\lyricsto "voice" \lyrControl
>>
\layout {
\context {
\Score
lyricMelismaAlignment = #-02.6
}
}
\header { piece = "all Lyrics are associated to a Voice" }
}
\markup \vspace #2
\score {
\new Staff <<
\new NullVoice = "nullvoice" \melody
\new Voice = "voice" \melody
\new Lyrics = "testI"
\with {
\override LyricText.X-offset = #center-on-word
instrumentName = "lyricsto nv"
}
\lyricsto "nullvoice" \lyr
\new Lyrics = "testII"
\with {
\override LyricText.X-offset = #center-on-word
instrumentName = "lyricsto nv"
}
\lyricsto "nullvoice" \lyrA
%% The control-voice omits the override
\new Lyrics = "control"
\with { instrumentName = "lyricsto nv" }
\lyricsto "nullvoice" \lyrControl
\new Lyrics = "control"
\with { instrumentName = "lyricsto v " }
\lyricsto "voice" \lyrControl
>>
\layout {
\context {
\Score
lyricMelismaAlignment = #-0.6
}
}
\header { piece = "First three Lyrics are associated to a NullVoice" }
}
HTH,
Harm
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: align-on-syllable.ly and 2.19.36,
Thomas Morley <=