Hi David, 2011/10/28 David Nalesnik <david.nales...@gmail.com>
> Hi Harm, > > On Tue, Oct 25, 2011 at 12:05 PM, harm6 <thomasmorle...@googlemail.com>wrote: > >> >> Hi David, >> >> David Nalesnik-2 wrote: >> > >> > Hi Harm, >> > >> > On Mon, Oct 24, 2011 at 4:09 PM, Thomas Morley < >> > thomasmorle...@googlemail.com> wrote: >> >> I'm looking for a method to integrate something like: >> >> (if (= number 0) >> use: \override Beam #'grow-direction = #LEFT >> (if (>= number stem-count) >> use: \override Beam #'grow-direction = #RIGHT >> otherwise use: \override Beam #'stencil = (grow-beam-var arg) >> >> into the Beam-stencil-override. >> >> I'm aware of the possibility to create a function to do that, but this is >> not intended. >> >> So, is it possible to program (grob-property-set! grob 'grow-direction >> LEFT) >> somewhere in a stencil-override? >> >> > I'm not sure I understand what you want here. Would you like to duplicate > the effect of these overrides in the function (say by adding in null > stencils), or actually call them when certain conditions are met? The > attached file does the latter. > Sorry, if I wasn't clear, but you did understand what I wanted! :) Now it works fine. (...) There are two problems left. >> First tiny problem: >> The output with kneed-beams is ugly in some cases: >> This example gives a overlooking stem at beam-end (test-code only) >> >> xy = \once\override Stem #'french-beaming = ##t >> >> \relative c { >> \once\override Beam #'stencil = #(grow-beam-var 5) >> f32 [ \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy >> f'''] >> } >> >> I'm not sure how to fix. 'french-beaming only works with the inner stems. >> Is there a default-command I can't find? Should I integrate something into >> the definition of grow-beam-var? Or create a separate override for this >> stem? >> >> > I don't know if there's a setting to allow 'french-beaming to work with > outer stems of a beam group. (I checked some Durand scores of Messiaen, and > sure enough, the outer stems span the entire beam.) I tried various > overrides to adjust the length of the final stem only, and the solution I > got to work is this: > > xy = \once\override Stem #'french-beaming = ##t > > \relative c { > \once \override Beam #'stencil = #(grow-beam-var 5) > f32 [ \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy > \once \override Stem #'stencil = #(lambda (grob) (ly:grob-set-property! > grob 'length 11) > (ly:stem::print grob)) > f'''] > } > I changed your suggestion to a function (I've no problems using a function in this case) and tested both: 1. It doesn't works with "2.14.2", but with "2.15.13" there are no problems. Does it work with "2.14.2" for you? 2. Using it with \change Staff doesn't work! Maybe an issue with \change Staff? \version "2.15.13" xy = \once\override Stem #'french-beaming = ##t #(define ((stem-length y) grob) (ly:grob-set-property! grob 'length y) (ly:stem::print grob)) xyOut = #(define-music-function (parser location y-length)(number?) #{ \once \override Stem #'stencil = #(stem-length $y-length) #}) % This works \relative c { \once \override Beam #'stencil = #(grow-beam-var 5) f32 [ \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xyOut #11 f'''] } % This not. Issue in \change Staff ? top = \change Staff = "1" bottom = \change Staff = "2" music = \relative c { \override Beam #'auto-knee-gap = #0 \override Beam #'stencil = #(grow-beam-var 1) \bottom cis32[ f %\xyOut #0 \once \override Stem #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'length 0) (ly:stem::print grob)) \top f''] } \score { \new PianoStaff << \new Staff = "1" { s16. } \new Staff = "2" { \clef bass \music } >> } > > >> Regarding the following example I'm not sure: should the peak point up or >> down? What do you think? >> >> \relative c' { >> \override Beam #'auto-knee-gap = #4 >> \override Beam #'stencil = #(grow-beam-var 16) >> c''32 [b a g >> f g a b >> c b a g >> f g a b >> e,,, c''' b a >> g a b c >> d c b a >> g a b c] >> c1 >> } >> > > Well, with the current position of the beam, what you have is the only > option. Otherwise the beam will cover the ledger lines. > To avoid covering the ledger lines I used a 'positions-override and changed the function a little to get the possibility to turn the peak up or down, if I use negative values. But only if the beam is kneed and level. I'm afraid it would be too much work to generalize this feature, needed only in very special cases. See attached file. > >> Second problem. >> I tried to use \featherDuration with my Definition, but it doesn't work as >> expected (seems it works only once a beam): >> >> (...) >> > > There's a "known warning" about \featherDurations which applies here, I > think. You have too many notes in the group. Your beams work with this > short example: > > \relative c'' { > \override Beam #'stencil = #(grow-beam-var 4) > \featherDurations #(ly:make-moment 1 2) > {c32[ c c c} \featherDurations #(ly:make-moment 2 1) {c c c c]} c2. > } > > Maybe you could think of some artful way to modify the function in > music-functions-init.ly to incorporate the increase/decrease. That way > you could handle the peak smoothly. > I knew about the "known warning", though, perhaps there is someone out there, who worked with it and could give me some hint. And I will try myself. :) > > I hope this helps! > >> > You leveled up my function 1000% at least! Thanks a lot! Harm
%\version "2.14.2" \version "2.15.13" \pointAndClickOff #(set-global-staff-size 18) \paper { tagline = ##f } \markup \column { \bold \fill-line { "EXAMPLES" } \vspace #2 } xy = \once\override Stem #'french-beaming = ##t #(define ((stem-length y) grob) (ly:grob-set-property! grob 'length y) (ly:stem::print grob)) xyOut = #(define-music-function (parser location y-length)(number?) #{ \once \override Stem #'stencil = #(stem-length $y-length) #}) #(define ((grow-beam-var number) grob) (cond ((< (length (cdr (ly:grob-property (ly:grob-parent grob X) 'beaming))) 2) (ly:beam::print grob)) ((= number 0) (begin (ly:grob-set-property! grob 'grow-direction LEFT) (ly:beam::print grob))) ((>= number (1- (ly:grob-array-length (ly:grob-object grob 'stems)))) (begin (ly:grob-set-property! grob 'grow-direction RIGHT) (ly:beam::print grob))) ((ly:stencil? (ly:beam::print grob)) ;; delete this? ;; Thanks to David Nalesnik (let* ((beam (ly:beam::print grob)) (dir (ly:beam::calc-direction grob)) (b-d (ly:output-def-lookup (ly:grob-layout grob) 'blot-diameter)) (beam-extent-X (ly:stencil-extent beam X)) (beam-length-x-orig (interval-length beam-extent-X)) (beam-length-x (- beam-length-x-orig b-d)) (beam-extent-Y (ly:stencil-extent beam Y)) (beam-length-y (interval-length beam-extent-Y)) (orig-beam-thickness (ly:grob-property grob 'beam-thickness)) (beam-count (length (cdr (ly:grob-property (ly:grob-parent grob X) 'beaming)))) ;; the number of beams (space-between-beams (* 0.46 (ly:grob-property grob 'gap))) ;; the space between the beams (orig-beam-length-at-stem (+ (* beam-count orig-beam-thickness)(* (- beam-count 1) space-between-beams))) (beam-positions (ly:grob-property grob 'positions)) (beam-slant (cond ((<= (car beam-positions) (cdr beam-positions)) 1) ;;((= (car beam-positions) (cdr beam-positions)) 0) ((> (car beam-positions) (cdr beam-positions)) -1))) (orig-slope (* beam-slant (/ (- beam-length-y orig-beam-length-at-stem) beam-length-x))) (alpha (atan orig-slope)) (beam-thickness (* 0.8 orig-beam-thickness)) (h-max (- (/ orig-beam-length-at-stem (cos alpha)) (* 1.3 beam-thickness))) ;;;;; (dir-peak (if (and (ly:grob-property grob 'knee) (< number 0) (= (car beam-positions) (cdr beam-positions))) -1 1)) (number-a (if (integer? (abs number)) (abs number) (inexact->exact (floor (abs number))))) (number-b (- (abs number) (floor (abs number)))) (stems (ly:grob-object grob 'stems)) (stem-count (ly:grob-array-length stems)) (refp (ly:grob-system grob)) (first-stem (ly:grob-array-ref stems 0)) (target-stem (if (< (abs number-a) stem-count) (ly:grob-array-ref stems number-a) (ly:grob-array-ref stems (- stem-count 1 )))) (next-stem (if (< (+ (abs number-a) 1) stem-count) (ly:grob-array-ref stems (+ number-a 1)) (ly:grob-array-ref stems (- stem-count 1 )))) (first-stem-coord (ly:grob-relative-coordinate first-stem refp X)) (target-stem-coord (ly:grob-relative-coordinate target-stem refp X)) (next-stem-coord (ly:grob-relative-coordinate next-stem refp X)) (first-stem-to-target-stem-length (interval-length (cons first-stem-coord target-stem-coord))) (stem-to-next-stem-length (interval-length (cons target-stem-coord next-stem-coord))) (factor (if (eq? first-stem target-stem);(= first-stem-to-target-stem-length 0) beam-length-x (/ beam-length-x first-stem-to-target-stem-length))) ;; markup-a is the longest beam (markup-a (markup #:beam beam-length-x orig-slope beam-thickness)) ;; left piece ;; y-length of left piece (y-L (lambda (n) (- (/ (- beam-length-y orig-beam-length-at-stem) factor) (* dir beam-slant (* n (/ h-max (- beam-count 1))))) )) ;; x-length of left piece (x-L (if (= number 0);(= first-stem-to-target-stem-length 0) 0.001 (+ first-stem-to-target-stem-length (* number-b stem-to-next-stem-length)))) ;; slope of left piece (slope-part-beam-L (lambda (n) (cond ((or (and (> dir 0) (> beam-slant 0)) (and (< dir 0) (> beam-slant 0))) (* dir-peak (/ (y-L n) x-L))) ((or (and (> dir 0) (< beam-slant 0)) (and (< dir 0) (< beam-slant 0))) (* -1 (/ (y-L n) x-L)))))) ;; construct left piece (part-beam-L (lambda (n) (markup #:beam x-L (slope-part-beam-L n) beam-thickness))) ;; markup of left piece (markup-L (lambda (n) (markup (part-beam-L n)))) ;; stencil of left piece (beam-part-L (lambda (n) (grob-interpret-markup grob (markup-L n)))) ;; y-extent of left piece (beam-part-L-ext-y (lambda (n) (ly:stencil-extent (beam-part-L n) Y))) ;; length of left piece (length-beam-part-L-y (lambda (n) (interval-length (beam-part-L-ext-y n)))) ;; right piece (y-R (lambda (n) (- (- beam-length-y orig-beam-length-at-stem) (y-L n)))) (x-R (- beam-length-x x-L)) (slope-part-beam-R (lambda (n) (cond ((or (and (> dir 0) (> beam-slant 0)) (and (< dir 0) (> beam-slant 0))) (* dir-peak (/ (y-R n) x-R))) ((or (and (> dir 0) (< beam-slant 0)) (and (< dir 0) (< beam-slant 0))) (* -1 (/ (y-R n) x-R)))))) (part-beam-R (lambda (n) (markup #:beam (- beam-length-x x-L) (slope-part-beam-R n) beam-thickness))) (markup-R (lambda (n) (markup (part-beam-R n)))) ;; parts of feathered beams (beam-pieces (map (lambda (n) (ly:stencil-combine-at-edge (ly:stencil-translate-axis (grob-interpret-markup grob (markup-L n)) -0.025 X) X RIGHT (ly:stencil-translate-axis (grob-interpret-markup grob (markup-R n)) (cond ((and (> dir 0)(> beam-slant 0)) (if (and (>= (slope-part-beam-L n) 0)(>= (slope-part-beam-R n) 0)) (- (length-beam-part-L-y n) beam-thickness) (* -1 (- (length-beam-part-L-y n) beam-thickness)))) ((and (> dir 0)(< beam-slant 0)) (* -1 (- (length-beam-part-L-y n) beam-thickness))) ((and (< dir 0)(> beam-slant 0)) (* dir-peak (- (length-beam-part-L-y n) beam-thickness))) ((and (< dir 0)(< beam-slant 0)) (if (and (<= (slope-part-beam-L n) 0)(<= (slope-part-beam-R n) 0)) (* -1 (- (length-beam-part-L-y n) beam-thickness)) (- (length-beam-part-L-y n) beam-thickness))) ) Y) 0)) (cdr (iota beam-count)))) ) ;; end of defs in let* (define (helper beam-pieces) (ly:stencil-add (car beam-pieces) (if (null? (cdr beam-pieces)) (car beam-pieces) (helper (cdr beam-pieces))))) (ly:stencil-translate-axis (ly:stencil-add ;; first (long beam) (ly:stencil-translate-axis (grob-interpret-markup grob markup-a) -0.025 X) ;; other beams (helper beam-pieces)) (car beam-positions) Y) ) ;; end of let* ) ) ) %--------------------- Test ---------------------------------------------------- \relative c' { \once \override Beam #'positions = #'(0.2 . 0.2) \override Beam #'auto-knee-gap = #4 \override Beam #'stencil = #(grow-beam-var -16) c''32 [b a g f g a b c b a g f g a b \xy e,,, c''' b a g a b c d c b a g a b c] \bar "" \break \override Beam #'stencil = #(grow-beam-var 16) c32 [b a g f g a b c b a g f g a b e,,, c''' b a g a b c d c b a g a b c] } % This works \relative c { \once \override Beam #'stencil = #(grow-beam-var 5) f32 [ \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xy f''' f,,, \xyOut #11 f'''] } % This not. Issue in \change Staff ? top = \change Staff = "1" bottom = \change Staff = "2" music = \relative c { \override Beam #'auto-knee-gap = #0 \override Beam #'stencil = #(grow-beam-var 1) \bottom cis32[ f %\xyOut #0 \once \override Stem #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'length 0) (ly:stem::print grob)) \top f''] } \score { \new PianoStaff << \new Staff = "1" { s16. } \new Staff = "2" { \clef bass \music } >> }
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user