Hi David, got back home and your example works well on 2.14.2! Great!

But I failed to make it work in my context. I tidied and reduced my
score and attached (3.4KiB).

I've tried using your capo spanner in the melodyA part, and in the
bassA part, and the melody gives error, and when in the bass part, the
capo spanner only lines up with notes.

You can see my commented out attempt in the melody section.

Again, your example does work, just mine that doesn't.

Thanks again,
Zenaan
\version "2.14.2"
\language english

% Capo notation wizardry:
#(define (capo grob)
  (let* ((orig (ly:grob-original grob))
         (siblings (if (ly:spanner? orig)
                       (ly:spanner-broken-into orig) '()))
         (total-found (length siblings)))

    (define (adjust-first-left piece)
      (let* ((sys (ly:grob-system piece))
             (cols (ly:grob-object sys 'columns))
             (cols-list (ly:grob-array->list cols))
             (nearest-non-musical
               (find
                 (lambda (col) (eq? #t (ly:grob-property col 'non-musical)))
                 (find-tail
                   (lambda (col)
                     (eq? col (ly:grob-object (ly:spanner-bound piece LEFT) 'axis-group-parent-X)))
                   (reverse cols-list)))))
        (ly:spanner-set-bound! piece LEFT nearest-non-musical)))

    (if (>= total-found 1)
        (if (eq? grob (car siblings))
            (adjust-first-left grob))
        (adjust-first-left grob))))

capoVHalf = {
  \once \override TextSpanner #'to-barline = ##t
  \once \override TextSpanner #'dash-fraction = #0.6
  \once \override TextSpanner #'(bound-details left-broken text) = ##f
  \once \override TextSpanner #'(bound-details left padding) = #0
  \once \override TextSpanner #'(bound-details left-broken padding) = #0.25
  \once \override TextSpanner #'(bound-details left text) = \markup { \tiny { "½ Capo V" } }
  \once \override TextSpanner #'after-line-breaking = #capo
}

% em   : E minor chord triplets:
emeb   = \relative b' \times 2/3 { b8  b, g }
emea   = \relative g' \times 2/3 { a8  b, g }
emeg   = \relative g' \times 2/3 { g8  b, g }

melodyA = \relative e' {
  \key e \minor
  \time 3/4
  \emeb  \emeb  \emeb   |
  \override TupletNumber #'transparent = ##t
  \emeb  \emea  \emeb   |
  \emeg  \emea  \emeb   |
  \emeg  \emea  \emeb   |

  %\capoVHalf
  \emeb
  %<> \startTextSpan
         \emea  \emeb   |
  \emeg
  %<> \stopTextSpan
         \emea  \emeb   |
  \emeg  \emea  \emeb   |
  \emeb  \emea  \emeb   |
}

bassA = \relative c, {
  \key e \minor
  \time 3/4
   e2.    e
   e      e |

  \capoVHalf
   a
  %<> \startTextSpan
   b
  \startTextSpan
   e,
  <> \stopTextSpan
   e
}

beginWithRepeatBar = {
  \once \override Score.BreakAlignment #'break-align-orders =
    #(make-vector 3 '(instrument-name
                      left-edge
                      ambitus
                      breathing-sign
                      clef
                      key-signature
                      time-signature
                      staff-bar
                      custos))
  \once \override Staff.TimeSignature #'space-alist =
    #'((first-note . (fixed-space . 2.0))
       (right-edge . (extra-space . 0.5))
       ;; free up some space between time signature
       ;; and repeat bar line
       (staff-bar . (extra-space . 1)))
  \bar "|:"
}

toCoda = {
  \once \override Score.RehearsalMark #'break-visibility = #end-of-line-visible
  \once \override Score.RehearsalMark #'self-alignment-X = #RIGHT
  \once \override Score.RehearsalMark #'padding = #2.5
  \mark \markup { \bold \tiny "To Coda" }
  \break
}

theSong = {
  \beginWithRepeatBar
  \repeat volta 2 << \melodyA \\ \bassA >>
  \toCoda
}

\book {
  \score {
    <<
      \new StaffGroup <<
        \new Staff {
          \clef "treble_8"
          \theSong
        }
        \new TabStaff {
          \theSong
        }
      >>
    >>
    \layout {
    }
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to