3

Drum charts are often very repetitive, so frequently a bar will have a repeat count indicated above it. Examples shown here:

example of drum rhythms with percent style repeat symbols, the number of repeats is represented as a large bold number above the symbol (from http://www.play-drums.com/Pad/lesson11-repeats.asp)


I've been able to do this in LilyPond by defining a function like so:

make_percent = #(define-music-function ()()
  "Make a percent repeat spanning one bar"
  (make-music 'PercentEvent
             'length (ly:make-moment 1))
)

percent_repeat = #(define-music-function (count) (integer?) 
  "Make a percent repeat with a bar count above"
  #{
    \once \override Staff.MeasureCounter.text = #(number->string count)
    <>\startMeasureCount
    \make_percent
    <>\stopMeasureCount
  #}
)

But this is less than ideal, I'd prefer to do it through \repeat percent somehow, but can't find a way.

Is there a way? Is this a feature request?

1 Answer 1

2

As far as I know this is currently not possible. You can trick MM rests to allow for such an behaviour, like this:

\version "2.22"

#(define (slash height slope thickness)
   (let* ((wid (/ height slope))
          (adjthick (/ thickness (sqrt (+ (* slope slope) 1))))
          (x0 0)
          (y0 0)
          (x1 (+ 0 adjthick))
          (y1 0)
          (x2 (+ wid adjthick))
          (y2 height)
          (x3 wid)
          (y3 height))
    (make-path-stencil
      `(moveto ,x0 ,y0 lineto ,x1 ,y1 lineto ,x2 ,y2 lineto ,x3 ,y3 lineto ,x0 ,y0)
      0.01
      1
      1
      #t)))

#(define-markup-command (slash layout props height slope thickness) (number? number? number?)
   (slash height slope thickness))

perc = \markup\concat{
  \raise #0.5 \musicglyph #"dots.dot"
  \hspace #-0.75
  \lower #1 \slash #2 #1 #0.98
  \hspace #-0.75
  \lower #0.5 \musicglyph #"dots.dot"
}

compress = \compressMMRests\etc

repeatWholeMeasure =
#(define-music-function (dur n) (ly:duration? number?)
   #{
     \temporary\override Staff.MultiMeasureRest.stencil =
     #(grob-transformer 'stencil
                        (lambda (grob orig)
                          (let* ((text (ly:text-interface::print grob))
                                 (ext-x (ly:stencil-extent orig X))
                                 (mid (interval-center ext-x))
                                 (t-ext-x (ly:stencil-extent text X))
                                 (mid2 (interval-center t-ext-x)))
                            (ly:stencil-translate-axis text (- mid mid2) X))))
     \temporary\override Staff.MultiMeasureRest.text = \perc
     \temporary\override Staff.MultiMeasureRest.spacing-pair.break-alignment = #'staff-bar
     \temporary\override Staff.MultiMeasureRest.bound-padding = #'()
     \temporary\override Staff.MultiMeasureRest.space-increment = #'()
     \temporary\override Staff.MultiMeasureRestNumber.padding = #1.5
     R $dur * $n
     \revert Staff.MultiMeasureRest.stencil
     \revert Staff.MultiMeasureRest.text
     \revert Staff.MultiMeasureRest.spacing-pair.break-alignment
     \revert Staff.MultiMeasureRest.bound-padding
     \revert Staff.MultiMeasureRest.space-increment
     \revert Staff.MultiMeasureRestNumber.padding
   #})

\new RhythmicStaff {
  4 8 8 8 8 4
  \compress \repeatWholeMeasure 1 5
}

% Advantage of this approach:

<<
  \new RhythmicStaff {
    4 8 8 8 8 4
    \compress \repeatWholeMeasure 1 5
  }
  \new RhythmicStaff {
    8 8 4 4 8 8 |
    4 4 8 8 8 8 |
    4 8 8 4 8 8 |
    4 4 4 4 |
    8 8 8 8 8 8 4 |
    4 2 8 8
  }
>>

but there is not really a way to collapse percent repeats. It would be most certainly doable if there is enough reason to have percent repeats compressable.

6
  • I don't understand why you have to draw the percent symbol from scratch. Dec 30, 2022 at 8:13
  • @ElementsinSpace Do you have a better way ready, or do you ask this out of interest?
    – Lazy
    Dec 30, 2022 at 8:16
  • lilypond.org/doc/v2.22/Documentation/notation/short-repeats shows a way to get an isolated percent repeat symbol Dec 30, 2022 at 8:24
  • I assume you could use that^ or something like it to draw the symbol. But maybe you have a good reason for drawing it from scratch, if so I'd like to know what that reason is. Dec 30, 2022 at 9:12
  • 1
    @ElementsinSpace If you are referring to the point Isolated percent repeats: This one creates a percent event, which is then (by the respective engraver) to a PercentRepeat grob, which will position a stencil. But we want to actually abuse a MultiMeasureRest grob to look like a percent repeat. But the percent is actually not an accessible symbol, but drawn using a C++-routine. So we have to create this stencil ourselves. Also this serves useful if you want to have percents with more than two slashes.
    – Lazy
    Dec 30, 2022 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.