lilypond-user
[Top][All Lists]
Advanced

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

Re: collision between slurs and and accidentals


From: Jonathan Kulp
Subject: Re: collision between slurs and and accidentals
Date: Wed, 27 May 2009 09:32:47 -0500
User-agent: Thunderbird 2.0.0.21 (X11/20090409)

-Eluze wrote:

kontrapunktstefan wrote:

Isn't there another possibilitie?

you might also try options like \slurUp, \slurDown, \voiceOne, \stemUp or
similar

Stefan,

If you like the results of this code, you have Mark Polesky to thank. This is something from the mailing list just a little while back. It produces some warnings in the terminal, but the output might be satisfactory. I think it looks pretty cool anyway. :)

Jon

--
Jonathan Kulp
http://www.jonathankulp.com

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.13.0"

%%%% SCHEME HACK TO HIDE CURVES WHEN THEY WOULD COLLIDE
%%%% you could store this whole bit in a definitions.ily file and put
%%%% \include "definitions.ily" at the top of your file, to keep
%%%% your code more tidy

#(define (parse-grob-sym grob-sym)
     (let* ((grob-str  (symbol->string grob-sym))
            (dot-index (string-index grob-str #\.))
            (context   (if dot-index
                           (string-take grob-str dot-index)
                           "Voice"))
            (grob      (if dot-index
                           (substring grob-str (+ dot-index 1))
                           grob-str)))
       (cons context grob)))

hideCurvesFrom =
#(define-music-function
   (parser location grob-sym
                    x-padding
                    y-padding)
   (symbol? pair? pair?)
   (let* ((context  (car (parse-grob-sym grob-sym)))
          (top-grob (cdr (parse-grob-sym grob-sym))))
#{
  \override Tie #'layer = #-2
  \override Slur #'layer = #-2
  \override PhrasingSlur #'layer = #-2

  \override $context . $top-grob #'avoid-slur = ##f
  \override $context . $top-grob #'layer = #-1
  \override $context . $top-grob #'stencil =
    #(lambda (grob)

       ;; get-stil-proc is a workaround because there may
       ;; be more than one 'stencil entry in basic-props
       (define (get-stil-proc alist)
         (let ((stil-proc (ly:assoc-get 'stencil alist)))
           (if (procedure-name stil-proc)
               stil-proc
               (begin (set! alist (assoc-remove! alist 'stencil))
                      (get-stil-proc alist)))))

       (let* ((basic-props (ly:grob-basic-properties grob))
              (stil-proc (get-stil-proc basic-props))
              (this-stil (stil-proc grob))
              (stil-x-ext (ly:stencil-extent this-stil 0))
              (stil-y-ext (ly:stencil-extent this-stil 1))
              (box-x-ext (cons (- (car stil-x-ext) (car $x-padding))
                               (+ (cdr stil-x-ext) (cdr $x-padding))))
              (box-y-ext (cons (- (car stil-y-ext) (car $y-padding))
                               (+ (cdr stil-y-ext) (cdr $y-padding))))
              (box-w (- (cdr box-x-ext) (car box-x-ext)))
              (box-h (- (cdr box-y-ext) (car box-y-ext))))
      (ly:stencil-add
       (ly:make-stencil
        (list 'embedded-ps
         (ly:format
          (string-append "gsave\n"
                         "currentpoint translate\n"
                         "1 setgray\n"
                         "~a ~a ~a ~a rectfill\n"
                         "grestore\n")
          (car box-x-ext)
          (car box-y-ext)
          box-w
          box-h))
        stil-x-ext
        stil-y-ext)
       this-stil)))
#}))

revertHideCurvesFrom =
#(define-music-function
   (parser location grob-sym)
   (symbol?)
   (let* ((context  (car (parse-grob-sym grob-sym)))
          (top-grob (cdr (parse-grob-sym grob-sym))))
#{
  \revert Tie #'layer
  \revert Slur #'layer
  \revert PhrasingSlur #'layer
  \revert $context . $top-grob #'avoid-slur
  \revert $context . $top-grob #'layer
  \revert $context . $top-grob #'stencil
#}))

%%%%% YOUR MUSIC STARTS HERE %%%%%%

{
  \hideCurvesFrom #'Staff.Accidental #'(0.3 . 0.3) #'(0 . 0)
  \time 7/8
    %\once \override Slur #'positions = #'(5 . 5 )
  dis''8 ([cis''' ) f''] ais''4 ais''  %looks better
  cis'' 8 ( [ b'') dis''] gis''4 gis''
  \time 6/8
  %\once \override Slur #'positions = #'(8 . 6 )
f''8 [ ( es''' ) g'' ] d'''([ b'') a'' ] %no collision to the tie, but still not convincing
  \time 2/4
  c'''4 c'''
}




reply via email to

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