2009/3/26 Kees Serier <a.ser...@hccnet.nl>:

> I have placed the \layout { ... } at several places in the ly files, and
> replaced the two e:m chords with one
>
> \repeat percent 2 {e:m}
> But nothing happens, I get no errors, and still 2 Em chords.
> Any ideas?

It won't work unless each chord is the duration of a full bar, since
\percent repeat uses this to distinguish between slashes and percent
symbols.  It's probably rather an unsatisfactory solution anyway,
since it depends on barlines being present (either added to the
ChordNames context if it's on its own, or getting them from staves
above/below).

For technical reasons, you can't simply override the ChordName stencil
using the percent repeat print-function
(ly:multi-measure-rest::percent), but it's possible to duplicate its
code in Scheme:

percentStencil =
#(lambda (grob)
   (define (sqr x)
     (* x x))
   (let* ((font (ly:grob-default-font grob))
          (dot (ly:font-get-glyph font "dots.dot"))
          (thick (ly:grob-property grob 'thickness))
          (slope (ly:grob-property grob 'slope))
          (dot-kern (- (ly:grob-property grob 'dot-negative-kern 0.75)))
          (width (/ 2 slope))
          (x-ext (cons
                  0
                  (+ width (sqrt (+ (sqr (/ thick slope)) (* thick thick))))))
          (y-ext (cons 0 (* width slope)))
          (slash (ly:make-stencil
                  (list 'repeat-slash width slope thick)
                  x-ext y-ext))
          (stil (ly:stencil-combine-at-edge
                 (ly:stencil-combine-at-edge
                  slash
                  X
                  LEFT
                  (ly:stencil-translate-axis dot 1.5 Y)
                  dot-kern)
                 X
                 RIGHT
                 (ly:stencil-translate-axis dot 0.5 Y)
                 dot-kern)))
     stil))

\score {
  <<
    \chords {
      c2 \once \override ChordName #'stencil = \percentStencil c
      \repeat percent 4 { e4:m }
      \repeat percent 2 { e1 }
    }
    \new Staff \relative c' {
      c2 c
      e1 | e | e
    }
  >>
  \layout {
    \context {
      \ChordNames
      \consists "Percent_repeat_engraver"
      \consists "Slash_repeat_engraver"
      \override RepeatSlash #'stencil = \percentStencil
      \override RepeatSlash #'slope = #1
    }
  }
}

Regards,
Neil


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

Reply via email to