I'm making a music function below to automatically create a repeat
structure. It's useable at the moment, but there are a couple of
improvements that could be made - any suggestions for these would be
very helpful.

1. The main problem is where to revert the bar number visibility
override. This needs to be done *after* the closing barline of the
repeat - the idea being that the bar following a repeat is always
numbered. Is there someway to schedule a delayed revert?

2. Ideally the [x3] markup should be right-aligned to the barline,
however I can't use "\mark" here since this is likely to coincide with a
real rehearsal mark in practice.

3. It would be nice not to have to specify the endbar as an argument,
however this requires access to the starting bar number and calculation
of the duration of the music. I've tried to incorporate the
"\applyContext" approach in the docs (Extending 2.6.1) - but I'm not
sure how to access this within a music-function.

Thanks, Mark

%%%%%%%%%%%%%%%%%
\version "2.18.0"

repeatBars = #(define-music-function
    (parser location times endbar music)
    (number? number? ly:music?)
    (_i "make a repeat structure")
    #{
    \tag #'part {
      \override Score.BarNumber.break-visibility = ##(#t #t #t)
      <>^\markup \box \concat { "×" \number #(ly:number->string times) }
      \repeat volta #times { $music }
      \set Score.currentBarNumber = #endbar
      % can't revert here as then the closing barnumber won't print
      %\revert Score.BarNumber.break-visibility
    }
    \tag #'score {
      \repeat unfold #times { $music }
    }
    #})

music = \relative c' {
  \repeat unfold 4 { c1 }
  \mark \default
  \repeatBars 3 8 { c4 d e f }
  \repeat unfold 4 { c1 }
}

\score { \new Staff { \removeWithTag #'score \music } }
\score { \new Staff { \removeWithTag #'part \music } }
%%%%%%%%%%%%%%%%%

-- 
Mark Knoop

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to