Hi,

I have a text spanner function that shows a player that they are playing in
simultaneous rhythm with one or more other players. I adapted it from code
I used for indicating colouration in renaissance music. It works fine, but
if it begins on the last note of a line, and the attached string is long,
it can extend right to the edge of the page (see picture attached).

What would be good is to be able to say

\sim \markup \left-column { "Vln 1," "Vln 2" }

if needed. Otherwise I could have it require a markup and get it to
concatenate within the function, but my Scheme skills are not up to this...

Thanks in advance,
Vaughan
\version "2.24.3"

%contrinuted by harm6
% after an idea by Nathan
% see: http://lists.gnu.org/archive/html/lilypond-user/2012-07/msg00036.html
% thanks to Mark Knoop

mySimBeginning = "┌ "
mySimEnding = "┐"

sim =
#(define-music-function (annotation)(string?) ; I want this to be a string or a markup
   #{
     \tag #'removeFromScore {
       \once \override TextSpanner.before-line-breaking =
       #(lambda (grob)
          (let* ((sz (ly:grob-property grob 'font-size 0.0))
                 (mult (magstep sz)))
            (begin
             (ly:grob-set-property! grob 'style 'none)
             (ly:grob-set-nested-property! grob
                                           '(bound-details left text)
                                           (markup #:scale (cons mult mult) (string-append mySimBeginning annotation)))
             (ly:grob-set-nested-property! grob
                                           '(bound-details right text)
                                           (markup #:scale (cons mult mult) mySimEnding))
             ;;Perhaps you may want to uncomment the following lines
             ;;and adjust the value (currently -0.5)
             (ly:grob-set-nested-property! grob
                                           '(bound-details left padding) -0.5)
             (ly:grob-set-nested-property! grob
                                           '(bound-details right padding) -0.5)
             (ly:grob-set-nested-property! grob
                                           '(bound-details left-broken text) #f)
             (ly:grob-set-nested-property! grob
                                           '(bound-details right-broken text) #f))))
       $(make-music 'EventChord 'elements (list
                                           (make-music
                                            'TextSpanEvent
                                            'span-direction -1)))
     }
   #})


simEnd = \tag #'removeFromScore \stopTextSpan

\score {
  \relative c' {
    c4 \sim "Vln1" c c c |
    \break
    % here it would be useful to say
    % \sim \markup \left-column { "Vln 1," "Vln, 2" }
    c c \simEnd c \sim "Vln 1, Vln, 2" c |
    \break
    c c \simEnd c c |
  }
  \layout {}
}

\paper {
  ragged-right = ##t
}

Reply via email to