\version "2.19.36" %% c/p from lily-library.scm because it's not public #(define (sign x) (if (= x 0) 0 (if (< x 0) -1 1))) foo = \override Beam.stencil = #(lambda (grob) (let* ((stil (ly:beam::print grob)) (beam-y-pos (ly:grob-property grob 'positions)) (beam-x-pos (ly:grob-property grob 'X-positions)) (stems (ly:grob-object grob 'stems)) (first-stem (ly:grob-array-ref stems 0)) (first-stem-length (ly:grob-property first-stem 'length)) (delta-beam-y-pos (- (cdr beam-y-pos) (car beam-y-pos))) (delta-beam-x-pos (- (cdr beam-x-pos) (car beam-x-pos))) (beam-height (lambda (n) (* (/ delta-beam-y-pos delta-beam-x-pos) n))) (beam-dir (ly:grob-property grob 'direction)) (slant (sign (- (cdr beam-y-pos) (car beam-y-pos)))) (thick 0.1) (duration (ly:grob-property (ly:grob-parent grob X) 'duration-log)) (beam-count (- duration 2)) (beam-thickness (ly:grob-property grob 'beam-thickness)) (space-between-beams (* 0.46 (ly:grob-property grob 'gap 0.8))) (orig-beam-length-at-stem (+ (* beam-count beam-thickness) (* (- beam-count 1) space-between-beams))) (padding-corr (min (max (+ 1 orig-beam-length-at-stem) 1.5) (* 0.5 (- first-stem-length orig-beam-length-at-stem)))) (x-start -0.4) (y-start 0) (x-end 1.5) (y-end (* beam-dir (+ padding-corr 0.5 (* beam-dir (beam-height 1.5))))) (slash (make-line-stencil thick x-start ;; start x y-start ;; start y x-end ;; stop x y-end ;; stop y ))) (ly:stencil-combine-at-edge stil Y beam-dir slash (- ;; set slash really at edge of beam: (if (or (and (>= slant 0) (> beam-dir 0)) (and (< slant 0) (< beam-dir 0))) (* delta-beam-y-pos (- beam-dir)) 0) ;; add sufficient padding padding-corr)))) startAcciaccaturaMusic = { <>\startGraceSlur \temporary \override Flag.stroke-style = #"grace" \temporary \foo } stopAcciaccaturaMusic = { \revert Beam.stencil \revert Flag.stroke-style <>\stopGraceSlur } \new Staff { \relative c' { \acciaccatura { d16 e f g } d4 \acciaccatura { d'16 c b a } d4 \acciaccatura { g16 a b c } d4 \acciaccatura { g16 a b c } d4 \clef bass \acciaccatura { d,,,16 c b a } g4 \acciaccatura { d16 c b a } g4 \acciaccatura { d16 c b a } g4 \acciaccatura { d16 c b a } g4 \acciaccatura { d'16 d d d } g4 } } \new Staff { \relative c' { \stemDown \acciaccatura { \stemDown d16 e f g } d4 \acciaccatura { \stemDown d'16 c b a } d4 \acciaccatura { \stemDown g16 a b c } d4 \acciaccatura { \stemDown g16 a b c } d4 \clef bass \acciaccatura { \stemDown d,,,16 c b a } g4 \acciaccatura { \stemDown d16 c b a } g4 \acciaccatura { \stemDown d16 c b a } g4 \acciaccatura { \stemDown d16 c b a } g4 \acciaccatura { \stemDown d'16 d d d } g4 } } \new Staff { \relative c'' { \acciaccatura { dis32[ e, a' bes, cis, d' ] } es,4 } } \new PianoStaff << \new Staff = "1" { s1*0 \grace { \foo \stemDown a'''16[ \change Staff = "2" \stemUp bes, \change Staff = "1" \stemDown fis''16 \change Staff = "2" \stemUp g] } \change Staff = "1" es'4 } \new Staff = "2" { \clef bass \grace s4 s4 } >>