2016-12-24 9:07 GMT+01:00 Andrew Bernard <andrew.bern...@gmail.com>: > Hi All, > > > > When adjusting the number of beams on stems on a beamed group that go across > a rest within the group, I often get the following type of issue: > > > > { > > c'32[ > > \set stemLeftBeamCount = #3 > > \set stemRightBeamCount = #1 > > c' c'16\rest > > \set stemLeftBeamCount = #1 > > \set stemRightBeamCount = #3 > > c'32 c'] > > } > > > > I am well aware that a way to deal with this is to create a new voice just > for the rests for the duration of the beamed set, but with hundreds of these > in my score this quickly becomes tiresome. > > > > This was previously discussed here: > > > > https://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00075.html > > > > But at this point in time, is there a magic setting amongst all the arcane > beam machinery that can assist with this? Or would it be unreasonable to > propose a request for enhancement to make this common scenario easier to > code? > > > > Sorry > > Andrew
Hi Andrew, below some coding which tries to do it all automagically. I'm pretty confident it will always work for beamed stems at rests, though not that sure for the beamed stems at notes. If you notice bugs please report back. \version "2.18.2" %% and higher #(define stem-at-rest? (lambda (stem) "Takes @var{stem}, which is supposed to be a stem-grob. Checks whether it belongs to a rest-grob" (ly:grob? (ly:grob-object (ly:grob-parent stem Y) 'rest)))) #(define (beam::reset-beamings beam) "Takes a beam-grob and resets the beaming-property for its stems. Resulting in only one conneting beam over rests. Beamlets are printed only if the stem is a single first/last or surrounded by rests or other notes." (let* ((stem-list (ly:grob-array->list (ly:grob-object beam 'stems))) (splitted-stems (split-list-by-separator stem-list (lambda (stem) (stem-at-rest? stem)))) (stem-groups (filter (lambda (l) (> (length l) 1)) splitted-stems))) (for-each (lambda (ls) (for-each (lambda (stem) (let ((beaming (ly:grob-property stem 'beaming)) (calc-beaming-part (reverse (iota (- (ly:grob-property stem 'duration-log) 2))))) (cond ((and (equal? stem (car ls)) (not (equal? stem (car stem-list)))) (ly:grob-set-property! stem 'beaming (cons '(0) calc-beaming-part))) ((and (equal? stem (last ls)) (not (equal? stem (last stem-list)))) (ly:grob-set-property! stem 'beaming (list calc-beaming-part 0)))))) ls)) stem-groups) (for-each (lambda (stem) (if (stem-at-rest? stem) (cond ((equal? stem (car stem-list)) (ly:grob-set-property! stem 'beaming '(#f 0))) ((equal? stem (last stem-list)) (ly:grob-set-property! stem 'beaming '((0) . #f))) (else (ly:grob-set-property! stem 'beaming '((0) 0)))))) stem-list))) resetBeaming = \override Beam.before-line-breaking = #beam::reset-beamings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXAMPLES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% two events \transpose c c'' { \cadenzaOn \resetBeaming c'32\rest[ c'] c'32[ c'\rest] } %% three events \transpose c c'' { \cadenzaOn \resetBeaming c'32[ c' c'] c'32[ c' c'\rest] c'32[ c'\rest c'] c'32\rest[ c' c'] c'32\rest[ c'\rest c'] c'32[ c'\rest c'\rest] <>^"resetBeaming-default and manually tweaked" <>^"which behaviour here?" c'32\rest[ c' c'\rest] c'32\rest[ %<>^"still manually tweakeable" \set stemRightBeamCount = #1 c' c'\rest] c'32\rest[ \set stemLeftBeamCount = #1 c' c'\rest] %% never working: %c'32\rest[ c'\rest c'\rest] } %% various \transpose c c'' { \cadenzaOn \resetBeaming c'32\rest[ c'\rest c' c'] c'32[ c'32\rest c'\rest c'] c'32[ c' c'\rest c'\rest] c'32[ c'32\rest c' c'\rest] c'32\rest[ c' c'\rest c'] c'32\rest[ c'32 c'16 c'32 c'\rest c'16 c'] c'32\rest[ c'32 c'64 c'32 c'\rest c'16 c'] } HTH, Harm
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user