Gestrichelte und/oder gepunktete Balken

Begonnen von ValidUserName, Samstag, 28. April 2018, 00:38

« vorheriges - nächstes »

ValidUserName

\version "2.19.81"

\include "lilypond-book-preamble.ly"

\paper {
  indent = 0
}

\layout {
  \context {
    \Score
    \remove Bar_number_engraver
  }
  \context {
    \Staff
    \omit TimeSignature
    \omit BarLine
  }
}

\new staff \relative {
c' 8 [ e g d f a e g b  s s s  c e g]
c,,16[ e g d f a e g b  s s s  c e g]
c,,32[ e g d f a e g b  s s s  c e g]
}

\new RhythmicStaff {
  \time 2/1
  1 2 4
  %\once \offset positions #'(-2 . 1) Beam
  8[ 16 32 64 \set stemLeftBeamCount = #4 \set stemRightBeamCount = #5 128  s512 s s]
}

Da wo Skips sind, hätte ich gerne dass der Balken nur als gestrichelte oder, besser noch, gepunktete Linie fortgesetzt wird. Ich vermute einmal, das lässt sich auf befriedigende Weise nur per selbstdefinierten Grobs lösen, und damit bin ich nach wie vor aufgeschmissen... Wer kann helfen?

harm6

Hallo,

Dein Vorhaben ist extrem kompliziert, da es keinerlei Möglichkeit gibt einen Beam partiell zu ändern.
Darüberhinaus gibt es keine Möglichkeit einen Beam an einem spacer zu verankern, das wird von LilyPond ignoriert. Auch gibt es für einen grob-override keine Möglichkeit spacer zu erkennen, da sie keinerlei grob initiieren.

Soweit die Probleme.

Allerdings kann man natürlich den Beam.stencil mehr oder weniger von Grund auf neu konstruieren und dabei 'hooks' einbauen an denen etwas besonderes passieren kann.
Im Code unten habe ich Stems gezählt und zwischen Stem Nr x und Nr y passierts.

Das Ganze ist natürlich extrem aufwendig. War aber Anlass mein `scheme-line-interface' voranzutreiben. Zumindest so weit, daß es hier anwendbar ist. Es ist immer noch 'work-in-progress'...


\version "2.19.81"

\include "scheme-lines-02.ly"

#(define (lists-map function ls)
   "Apply @var{function} to @var{ls} and all of it sublists.
First it recurses over the children, then the function is applied to
@var{ls}."
   (if (list? ls)
       (set! ls (map (lambda (y) (lists-map function y)) ls))
       ls)
   (function ls))

#(define (customized-beam-part start-stem stop-stem) 
  (lambda (grob)
    (let* ((pos (ly:grob-property grob 'positions))
           (x-pos (ly:grob-property grob 'X-positions))
           (slope (/ (- (cdr pos) (car pos)) (interval-length x-pos)))
           (thick (ly:grob-property grob 'beam-thickness))
           (segments (ly:grob-property grob 'beam-segments))
           (dir (ly:grob-property grob 'direction))
           ;(beam-length-fraction (ly:grob-property grob 'length-fraction 1))
           (gap (ly:grob-property grob 'gap 0))
           (details (ly:grob-property grob 'details '()))
           (on (assoc-get 'on details 1))
           (off (assoc-get 'off details 1))
           (style (ly:grob-property grob 'style 'polygon))
           (refp (ly:grob-system grob))
           (grob-layout (ly:grob-layout grob))
           (blot (ly:output-def-lookup grob-layout 'blot-diameter))
           (stems (ly:grob-object grob 'stems))
           (first-stem
             (ly:grob-array-ref stems 0))
           (target-stem-1
             (ly:grob-array-ref stems start-stem))
           (target-stem-2
             (ly:grob-array-ref stems stop-stem))
           (first-stem-x-ext
             (ly:stencil-extent (ly:grob-property first-stem 'stencil) X))
           (first-stem-x-coord
             (ly:grob-relative-coordinate first-stem refp X))
           (target-stem-1-x-coord
             (ly:grob-relative-coordinate target-stem-1 refp X))
           (target-stem-2-x-coord
             (ly:grob-relative-coordinate target-stem-2 refp X))
           (beams-to-recreate 0)
           (target-interval
             (cons
               (- target-stem-1-x-coord (car first-stem-x-ext))
               (- target-stem-2-x-coord (cdr first-stem-x-ext))))
           (nested-remaining-beams
             (lists-map
               (lambda (e)
                 (let* ((horizontal-interval
                          (if (list? e)
                              (assoc-get 'horizontal e #f)
                              #f)))
                 (if (and (pair? horizontal-interval)
                          (< (car horizontal-interval) (car target-interval))
                          (> (cdr horizontal-interval) (cdr target-interval)))
                     (begin
                       (set! beams-to-recreate (1+ beams-to-recreate))
                       (list
                         (list
                           (car e)
                           (cons
                             'horizontal
                             (cons
                               (car horizontal-interval)
                               (car target-interval))))
                         (list
                           (car e)
                           (cons
                             'horizontal
                             (cons
                               (cdr target-interval)
                               (cdr horizontal-interval))))))
                     e)))
               segments))
           (un-nested-remaining-beams
             (append-map
               (lambda (e) (if (list? (car e)) e (list e)))
               nested-remaining-beams)))
               
      (ly:grob-set-property! grob 'beam-segments un-nested-remaining-beams)
     
      (apply
        ly:stencil-add
        (ly:beam::print grob)
        (map
          (lambda (count)
            (let ((x-start (+ (- (car target-interval) first-stem-x-coord) gap))
                  (x-end (- (cdr target-interval) first-stem-x-coord gap)))
              (ly:stencil-translate-axis
                (scheme-line-interface
                  style
                  thick
                  ;x-start
                  x-start
                  ;y-start
                  (+
                     (car pos)
                     (/ blot -2)
                     (* x-start slope))
                  ;x-end
                  x-end
                  ;y-end
                  (+
                     (car pos)
                     (/ blot -2)
                     (* x-end slope))
                  (cons 'off off)
                  (cons 'on on))
                ;; Mmmhh, where does this magic 0.8 comes from?
                (* -1 dir count 0.8)
                Y)))
          (iota beams-to-recreate))))))
         
customizeBeamPart =
#(define-music-function (style between-stem-pair) (symbol? pair?)
"@var{between-stem-pair} is a pair of stems.  Note they are counted starting
with zero.  Between them the default beam will be replaced by lines printed
according to the style specifies with @var{style}.
Possible values are @code{dotted-line}, @code{'dashed-line},
@code{'dashed-polygons-line}"
#{
  \override Beam.style = #style
  \override Beam.stencil =
    #(customized-beam-part (car between-stem-pair) (cdr between-stem-pair))
#})

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\new Staff {
c'32[ d' s16 b'16 c'']
    \customizeBeamPart
      #'dotted-line
      #'(1 . 2)

    %% further adjustable via:
    \override Beam.details.off = 0.2
    \override Beam.details.on = 0.5
    \override Beam.gap = 0.6
c'32[
d'
s16
b'16
c'']
}


\new Staff \relative {
  \override Beam.gap = 0.6
  \override Beam.details.off = 0.2
  \customizeBeamPart
    #'dotted-line
    #'(8 . 9)
  c' 8 [ e g d f a e g b  s s s  c e g]
  c,,16[ e g d f a e g b  s s s  c e g]
  c,,32[ e g d f a e g b  s s s  c e g]
}



HTH,
  Harm

ValidUserName

Sieht soweit gut aus. Vielen Dank. Werde mich da mal ein bischen in den Code reinlesen.