2015-09-01 22:59 GMT+02:00 Martin Lejeune <[email protected]>: > Hi Everybody, > here's a newbie question. > I tried to configure "merging automatically" of rests in polyphonic staffs > (piano) with a snipped, which I found in the manual.
You likely mean http://lsr.di.unimi.it/LSR/Item?id=336 Though, please note, it's the "LilyPond Snippet Repository", LSR The LSR is _not_ part of the manuals. A lot of snippets are taken from the LSR and included in the snippets-manual. That's not exactly the same, though ;) > It doesn't work. It does. > What's the mistake, any idea? If you use a snippet, you have to include the _whole_ snippet into your file!!!! You deleted the entire definition of `merge-rests-on-positioning'!!! Additionally, there are several mistakes in your code of the snippet. Again, if you want to try a snippet copy and paste it in your file _without_ any changes! Try it and _afterwards_ you may try to apply changes. Read the description: "[...] Please note that multi-measure rests are not automatically combined" There are engravers on the list you may want to try, affecting simple rests and MultiMeasureRests, though they are not perfect, either: http://www.mail-archive.com/lilypond-user%40gnu.org/msg69703.html > > Thanks very much! > > Cheers > Martin > > PS: > > My example: Your example could be then: #(define has-one-or-less (lambda (lst) (or (null? lst) (null? (cdr lst))))) #(define has-at-least-two (lambda (lst) (not (has-one-or-less lst)))) #(define (all-equal lst pred) (or (has-one-or-less lst) (and (pred (car lst) (cadr lst)) (all-equal (cdr lst) pred)))) #(define merge-rests-engraver (lambda (context) (let ((rest-same-length (lambda (rest-a rest-b) (eq? (ly:grob-property rest-a 'duration-log) (ly:grob-property rest-b 'duration-log)))) (rests '())) `((start-translation-timestep . ,(lambda (trans) (set! rests '()))) (stop-translation-timestep . ,(lambda (trans) (if (and (has-at-least-two rests) (all-equal rests rest-same-length)) (for-each (lambda (rest) (ly:grob-set-property! rest 'Y-offset 0)) rests)))) (acknowledgers (rest-interface . ,(lambda (engraver grob source-engraver) (if (eq? 'Rest (assoc-ref (ly:grob-property grob 'meta) 'name)) (set! rests (cons grob rests)))))))))) #(define merge-mmrests-engraver (lambda (context) (let* ((mmrest-same-length (lambda (rest-a rest-b) (eq? (ly:grob-property rest-a 'measure-count) (ly:grob-property rest-b 'measure-count)))) (merge-mmrests (lambda (rests) (if (all-equal rests mmrest-same-length) (let ((offset (if (eq? (ly:grob-property (car rests) 'measure-count) 1) 1 0))) (for-each (lambda (rest) (ly:grob-set-property! rest 'Y-offset offset)) rests))))) (curr-rests '()) (rests '())) `((start-translation-timestep . ,(lambda (trans) (set! curr-rests '()))) (stop-translation-timestep . ,(lambda (trans) (if (has-at-least-two curr-rests) (set! rests (cons curr-rests rests))))) (finalize . ,(lambda (translator) (for-each merge-mmrests rests))) (acknowledgers (rest-interface . ,(lambda (engraver grob source-engraver) (if (eq? 'MultiMeasureRest (assoc-ref (ly:grob-property grob 'meta) 'name)) (set! curr-rests (cons grob curr-rests)))))))))) \version "2.18.2" \header { title = "merging rests" } global = { \time 4/4 } Key = { \key g\major } %% ------ Piano ------ rhUpper = \relative c'' { \voiceOne \Key R1*4 g4 r8 g r2 | } rhLower = \relative c' { \voiceTwo \Key R1*4 b4 r8 b r2 | } lhUpper = \relative c' { \voiceOne \Key R1*4 | g4 r8 g r2 | } lhLower = \relative c { \voiceTwo \Key R1*4| d4 r8 d r2 | } PianoRH = { \clef treble \global \set Staff.midiInstrument = #"acoustic grand" << \new Voice = "one" \rhUpper \new Voice = "two" \rhLower >> } PianoLH = { \clef bass \global \set Staff.midiInstrument = #"acoustic grand" << \new Voice = "one" \lhUpper \new Voice = "two" \lhLower >> } piano = { << \set PianoStaff.instrumentName = #"Piano" \new Staff = "upper" \PianoRH \new Staff = "lower" \PianoLH \set Staff.shortInstrumentName = #"p" >> } \score { << \new PianoStaff = "piano" \piano >> \layout { \context { \Staff \RemoveEmptyStaves \consists #merge-mmrests-engraver \consists #merge-rests-engraver } \context { \Score \override BarNumber.padding = #3 skipBars = ##t } } } HTH, Harm _______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
