Hello Graham,
allow me to advertise a feature recently (though before 2.19.21, which
you were using) introduced by David K.: Music functions may now directly
be called as Scheme procedures, so
#{ \italic #syllable #}
may be replaced with the much more elegant
(italic syllable)
!!!
Revised version in attachment.
Yours, Simon
On 16.12.2015 18:04, Graham King wrote:
Many thanks to both Davids for their help. In case anyone is remotely
interested, here is the working result. There is still a niggling
issue with lyrics that are both coloured and editorial, but I can live
with that for the time being.
-- Graham
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
\version "2.19.21"
%{
Allow editorial additions to underlay to be italic or [bracketed] (default).
Allow colouration in underlay, signifying reduced forces, to be
red or italic (default).
This only works with \lyricsto or \addlyrics due to the hardcoded duration.
Based on Simon Albrecht's code (see lilypond-user list 4 Dec 2015)
with further help from David Kastrup and David Nalesnik.
Limitation: expect trouble if coloured and editorial lyrics overlap.
%}
%%% Coloured underlay %%%
coloured =
#(define-music-function (parser location syllable)(string?)
#{
\temporary \override LyricText.color = #red
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
#})
endColour =
#(define-music-function (parser location syllable)(string?)
#{
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
\revert LyricText.color
#})
wrapColour =
#(define-music-function (parser location syllable)(string?)
#{
\temporary \override LyricText.color = #red
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
\revert LyricText.color
#})
%%% Italic underlay %%%
italic =
#(define-music-function (parser location syllable)(string?)
#{
\temporary \override LyricText.font-shape = #'italic
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
#})
endItalic =
#(define-music-function (parser location syllable)(string?)
#{
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
\revert LyricText.font-shape
#})
wrapItalic =
#(define-music-function (parser location syllable)(string?)
#{
\temporary \override LyricText.font-shape = #'italic
#(make-music
'LyricEvent
'text
(format "~a" syllable)
'duration
(ly:make-duration 2))
\revert LyricText.font-shape
#})
%}
%%% Bracketed underlay %%%
openBracket =
#(define-music-function (parser location syllable)(string?)
(make-music
'LyricEvent
'text
(format "[~a" syllable)
'duration
(ly:make-duration 2)))
closeBracket =
#(define-music-function (parser location syllable)(string?)
(make-music
'LyricEvent
'text
(format "~a]" syllable)
'duration
(ly:make-duration 2)))
wrapBrackets =
#(define-music-function (parser location syllable)(string?)
(make-music
'LyricEvent
'text
(format "[~a]" syllable)
'duration
(ly:make-duration 2)))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Decide what we want:
#(define lyricColourationStyle
(if (defined? 'lyricColourationStyle)
lyricColourationStyle
"italic"))
#(define lyricEditorialStyle
(if (defined? 'lyricEditorialStyle)
lyricEditorialStyle
"bracketed"))
#(ly:message "lyricColourationStyle: ~a" lyricColourationStyle)
#(ly:message "lyricEditorialStyle: ~a" lyricEditorialStyle)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
editorial =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricEditorialStyle "italic")
(italic syllable))
((string=? lyricEditorialStyle "bracketed")
(openBracket syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
editorialEnding =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricEditorialStyle "italic")
(endItalic syllable))
((string=? lyricEditorialStyle "bracketed")
(closeBracket syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
editorialWrap =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricEditorialStyle "italic")
(wrapItalic syllable))
((string=? lyricEditorialStyle "bracketed")
(wrapBrackets syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
colour =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricColourationStyle "italic")
(italic syllable))
((string=? lyricColourationStyle "red")
(coloured syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
colourEnding =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricColourationStyle "italic")
(endItalic syllable))
((string=? lyricColourationStyle "red")
(endColour syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
colourWrap =
#(define-music-function (parser location syllable)(string?)
(cond
((string=? lyricColourationStyle "italic")
(wrapItalic syllable))
((string=? lyricColourationStyle "red")
(wrapColour syllable))
(else (ly:message "invalid lyricEditorialStyle: ~a" lyricEditorialStyle)))
)
%%{ Test harness begins:
#(define lyricColourationStyle "red")
#(define lyricEditorialStyle "italic")
theNotes = {
\relative { e''1 d c e d2 d c1 \break g' f e g f2 f e1 }
}
theWords = \lyricmode {
Three \editorial blind \editorialEnding mice, see how \editorialWrap they run.
Three \colour blind \colourEnding mice, see how \colourWrap they run.
}
\score
{
\new StaffGroup
<<
\new Voice = "voice" \theNotes
\new Lyrics \lyricsto "voice" \theWords
>>
}
%%} %Test harness ends.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user