\version "2.16.0" % cue function that typesets associated lyrics cueDuringWithLyrics = #(let ((stafftag 'Staff) (cuenr 0)) ; cue voice counter, if there are multiple simultaneous quotes (define (cue-id) (set! cuenr (+ 1 cuenr)) (format "cue~A" cuenr)) ; get context property for alignment (define (alignlyrics direction)(if (eq? UP direction) 'alignAboveContext 'alignBelowContext)) ; the music function (define-music-function (parser location quote direction lyrics music) (string? integer? ly:music? ly:music?) ; we need the staff-id of the contained cueVoice ; and we need a cue-id (let ((staffid #f) (cueid (cue-id))) ; dummy engraver to get the parental staff-id (define (getstaffid context) (let ((staff (ly:context-find context stafftag))) (if (ly:context? staff) (set! staffid (ly:context-id staff))) ; this engraver does nothing (list))) ; engraver to set the lyric alignment (define (aligncue context) `((initialize . ,(lambda (trans) ; if we have a staff-id ... (if (string? staffid) ; ... set the alignment property (ly:context-set-property! context (alignlyrics direction) staffid) )) ))) ; now create the music #{ << % the music voiceOne/Two for UP/DOWN resp. { $(if (eq? direction UP) #{ \voiceTwo #} #{ \voiceOne #}) $music } \new CueVoice = $cueid \with { % create CueVoice with staff-id grabbing engraver \consists #getstaffid } { % the cued music voiceOne/Two for UP/DOWN resp. $(if (eq? direction UP) #{ \voiceOne #} #{ \voiceTwo #}) % the cue is quoted, use a skip event ... the music is in the main part \quoteDuring $quote { $(skip-of-length music) } } % create the lyrics with smaller text-size \new Lyrics \with { % the alignment setter fetches the grabbed staff-id \consists #aligncue fontSize = -2 \override LyricText #'font-shape = #'italic } % lyricsto the CueVoice \lyricsto $cueid \lyricmode { $lyrics } >> % reset voice to oneVoice \oneVoice #} ))) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% Example % create quote \addQuote "myquote" \relative c'' { \repeat unfold 10 { bes4 a c b } } % make music ... << % staff with a unique context-id \new Staff = "mystaff1" { R1 % cue with lyrics: one syllable less than needed \cueDuringWithLyrics "myquote" #DOWN \lyricmode { b a c h x y z } { R1*2 } % more music \relative c'' \repeat unfold 4 { c4 a f d } } \new Staff = "mystaff2" { R1 % cue with lyrics: more syllables than needed \cueDuringWithLyrics "myquote" #UP \lyricmode { b a c h x y z q q q } { R1*2 } % the following notes are shifted, if the last cue-note has a syllable? \relative c'' \repeat unfold 4 { c4 a f d } } >>