Hi James, Paolo,
2011/12/25 James <[email protected]>:
> Hello,
>
>
>
> On 25 December 2011 13:31, Paolo Prete <[email protected]> wrote:
>> thanks Thomas, it works greatly and imho it should be added to the snippets
>> repo
>
> Go for it!
>
> http://lsr.dsi.unimi.it/LSR/html/contributing.html
>
> James
>
I only upgraded the old snippet Paolo mentioned in his initial mail,
according to the new behaviour of #{ #}.
Though, that's the reason it can't be added to the LSR. The LSR still
uses "2.12.2".
My own attempt is a little different. In the attached file I try to
automate the slash-setting. If the output is not convincing or someone
wants more control, the second definition of that file may be used.
Cheers,
Harm
\version "2.15.20"
slash = {
\once \override Stem #'stencil =
#(lambda (grob)
(let* ((x-parent (ly:grob-parent grob X))
(is-rest? (ly:grob? (ly:grob-object x-parent 'rest)))
(is-beam? (ly:grob? (ly:grob-object grob 'beam)))
(is-flag? (ly:grob? (ly:grob-object grob 'flag)))
(dir (ly:grob-property grob 'direction))
(stem (ly:stem::print grob))
(stem-y (ly:grob-extent grob grob Y))
(stem-length (- (cdr stem-y) (car stem-y)))
(duration (ly:grob-property grob 'duration-log))
(line-x 2))
(cond (is-rest?
empty-stencil)
((and (not is-beam?) (not is-flag?))
(ly:stencil-add
stem
(ly:stencil-translate
(grob-interpret-markup grob (markup #:rotate 35 #:draw-line (cons line-x 0)))
(cons (/ line-x -2)
(if (= dir 1)
(- (cdr stem-y) (* stem-length 0.3))
(+ (car stem-y) (* stem-length 0.3)))))))
((and is-flag? (not is-beam?))
(ly:stencil-add
stem
(ly:stencil-translate
(grob-interpret-markup grob (markup #:rotate (* dir 35) #:draw-line (cons line-x 0)))
(cons (/ line-x (if (= dir 1)
-2.3
-3.3))
(if (= dir 1)
(- (cdr stem-y) (* stem-length 0.5))
(+ (car stem-y) (* stem-length 0.4)))))))
(else
(let* ((beam (ly:grob-object grob 'beam))
(beam-count (- duration 2))
(beam-thickness (ly:grob-property beam 'beam-thickness))
(space-between-beams (* 0.46 (ly:grob-property beam 'gap)))
(beam-positions-x (ly:grob-property beam 'X-positions))
(beam-length-x (interval-length beam-positions-x))
(beam-positions-y (ly:grob-property beam 'positions))
(beam-length-y (- (cdr beam-positions-y) (car beam-positions-y)))
(beam-slope (/ beam-length-y beam-length-x))
(beam-slant (cond ((<= (car beam-positions-y) (cdr beam-positions-y)) 1)
((> (car beam-positions-y) (cdr beam-positions-y)) -1)))
(orig-beam-length-at-stem (+ (* beam-count beam-thickness)
(* (- beam-count 1) space-between-beams)))
(slash-x-length (+ 2.4 (* orig-beam-length-at-stem 0.8)))
(slash-mrkp (markup #:rotate (+ (* 45 dir) (* 3 dir beam-count))
#:draw-line (cons slash-x-length beam-slope))))
(ly:stencil-add
stem
(ly:beam::print beam)
(ly:stencil-translate
(grob-interpret-markup grob slash-mrkp)
(cons (/ slash-x-length -2.5)
(if (= dir 1)
(- (cdr stem-y) (max 0.7 (* orig-beam-length-at-stem 0.4)))
(+ (car stem-y) (max 0.7 (* orig-beam-length-at-stem 0.4))))))))))))
}
music = \relative c'' {
\key cis\major
\slash r2
\slash a4
\slash c4
\slash a8
\noBeam
\slash c8
\acciaccatura { \slash d32 [e] } \slash c4
\acciaccatura d32 \slash c2
\slash c,8[ f']
\slash c16[ d e f]
\slash f32[ e d c]
\slash f,64[ e d c]
\acciaccatura { \slash c,128[ d e f'] } g4
\acciaccatura { \slash c128[ d e f] } g4
\acciaccatura { \slash f128[ e d c] } b4
\acciaccatura { \slash f,128[ e d c] } b8
}
\new Staff { \music }
\version "2.15.20"
onceSlash =
#(define-music-function (parser location line offset)(pair? pair?)
#{
\once \override Stem #'stencil =
#(lambda (grob)
(let* ((x-parent (ly:grob-parent grob X))
(is-rest? (ly:grob? (ly:grob-object x-parent 'rest)))
(stem (ly:stem::print grob))
(slash-mrkp (markup (#:override '(thickness . 1.5)
#:draw-line (cons (car line) (cdr line))))))
(if is-rest?
empty-stencil
(ly:stencil-add
stem
(ly:stencil-translate
(grob-interpret-markup grob slash-mrkp)
(cons (car offset) (cdr offset)))))))
#})
\relative c' {
\onceSlash #'(1.3 . 2.8) #'(-0.4 . 1.2)
c8 [ f']
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user