lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beam with breaks


From: Thomas Morley
Subject: Re: Beam with breaks
Date: Tue, 2 Aug 2016 19:13:32 +0200

2016-08-02 17:13 GMT+02:00 Andrew Bernard <address@hidden>:
> Hi Harm,
>
> Thank you for this. I suppose I was not clear enough, as usual. I
> explicitly need the beams on the individual note to have a longer
> beamlet on the top, with the rest being shorter. This is what I am
> unable to achieve. So it's not the beam break that I can't do, rather,
> it is the adjustment of the lengths of the beamlets. Can that be done
> with any lilypond magic?
>
> Andrew

Hi Andrew,

next try below ;)
The comments should explain what's going on, if not shout.

\version "2.19.45"

affectMainBeam =
#(define-music-function (val-list)(number-pair-list?)
"
 We get the 'beam-segments, rebuilding it modified.
 The 'beam-segments-property is an alist of type:
    '(((vertical-count . 0) (horizontal 3.865018 . 5.93))
      ((vertical-count . 1) (horizontal 3.865018 . 5.93)))

    `vertical-count' is the beam-count.
    `horizontal' is the x-extent relative to 'System!!
    I.e. the appearance will alter, when spacing changes.

 The values given in @var{val-list} are added to the horizontal extent.
"
#{
  \once \override Beam.beam-segments =
    #(lambda (grob)
       (let* ((beam-segments (ly:beam::calc-beam-segments grob))
              (main-beams
                (append-map
                  (lambda (beam-seg)
                    (if (= (assoc-get 'vertical-count beam-seg) 0)
                        (cdr beam-seg)
                        '()))
                  beam-segments))
              (main-beams-horizontal-ext (map cdr main-beams))
              (new-main-beamsegments
                (map
                  (lambda (pair-ext pair-vals)
                    (cons
                      (cons 'vertical-count 0)
                        (list
                          (cons 'horizontal
                            (cons
                              (+ (car pair-ext) (car pair-vals))
                              (+ (cdr pair-ext) (cdr pair-vals)))))))
                main-beams-horizontal-ext
                (append val-list (circular-list '(0 . 0))))))
         (append new-main-beamsegments beam-segments)))
#})

%% In the following example there is _one_ Beam, which has _three_ segments.
%% So the list-argument to `affectMainBeam' has three entries.
%% '(0 . 0) is ofcourse the neutral argument
%% If less entries then beam-segments are given sufficient instancies of
%% '(0 . 0) are added in the function.
%%
%% Not tested for kneed Beams or Beams over line-break.
example = {
  \affectMainBeam #'((0 . 2) (0 . 0) (-2 . 0))
  b!32[
  \set stemLeftBeamCount = #2
  \set stemRightBeamCount = #1
  a'16
  \set stemLeftBeamCount = #0
  \times 2/3 {
        fes'8
        \set stemLeftBeamCount = #2
        \set stemRightBeamCount = #0
        f16 g'32]~
  } g'16
}

{ \voiceOne \example \voiceTwo \example }


HTH,
  Harm

Attachment: atest-37.preview.png
Description: PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]