Re: hiding portions of slurs/ties around specific objects
Mark Polesky wrote: So the command \override Fingering #'avoid-slur = ##f will trigger the warning only if there's actually a fingering in the score following the command. Does anyone know an easier way to find which grobs trigger this warning? Then I can incorporate it into the macro and save a little frustration for future users. I just realized that for the macro to work properly, 'avoid-slur really should be set to #f for all slur-hiding grobs. Better yet would be a value like 'ignore (which doesn't exist yet). Although I proposed it on -devel: http://lists.gnu.org/archive/html/lilypond-devel/2009-04/msg00129.html Anyway, the mess that looks like this: \override $context . $top-grob #(if (or ;; append to this list if you get the warning: ;; Ignoring grob for slur: grob. avoid-slur not set? (equal? $top-grob Fingering) (equal? $top-grob Accidental) ) 'stencil 'avoid-slur) = ##f ...should really just be: \override $context . $top-grob #'avoid-slur = ##f One compromise is to set 'avoid-slur to 'around: \override $context . $top-grob #'avoid-slur = #'around This has the same effect of setting it to #f in many grobs, but not all, so it's not the ideal solution. The real problem then, is suppressing the warning messages you get when setting 'avoid-slur to #f, which could easily happen dozens of times during a single compile. Off hand, I don't know how to do that, and if you do, you may want to reply to the thread linked above. But the functionality of the macro comes first, so I'm attaching it, in what may be the final form for now, warning messages and all. Cheers. - Mark \version 2.13.0 #(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 #})) %% EXAMPLE %% % { \version 2.13.0 \pointAndClickOff \relative { \repeat volta 2 { %% syntax: \hideCurvesFrom [grob] [x-padding] [y-padding] % always call \hideCurvesFrom before the curve starts: \hideCurvesFrom #'Fingering #'(0.3 . 0.3) #'(0 . 0) \hideCurvesFrom
Re: hiding portions of slurs/ties around specific objects
On Thu, Apr 09, 2009 at 10:22:57PM -0700, Mark Polesky wrote: Perhaps it was a coincidence that both Kieren and Maestraccio requested slur-hiding solutions recently: http://lists.gnu.org/archive/html/bug-lilypond/2009-03/msg00106.html http://lists.gnu.org/archive/html/lilypond-user/2009-04/msg00153.html I tried to solve both individually, but then realized that a generic solution was best, so here it is. The name is not very poetic though. Thanks, Neil and Patrick, for your coding help and suggestions. You're welcome. Questions and comments are welcome. If anyone wants to add it to the LSR, that's fine by me. Change the function name too, if you want, I couldn't think of anything better. Very awesome! It's definitely LSR worthy. I was just trying to figure out a way to capture the right 'stencil entry, but you were far ahead of me. -Patrick ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: hiding portions of slurs/ties around specific objects
Questions and comments are welcome. If anyone wants to add it to the LSR, that's fine by me. Change the function name too, if you want, I couldn't think of anything better. Very awesome! It's definitely LSR worthy. +1 ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: hiding portions of slurs/ties around specific objects
M Watts wrote: Questions and comments are welcome. If anyone wants to add it to the LSR, that's fine by me. Change the function name too, if you want, I couldn't think of anything better. Very awesome! It's definitely LSR worthy. +1 Wow! Nice, Mark!! Jon -- Jonathan Kulp http://www.jonathankulp.com ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: hiding portions of slurs/ties around specific objects
One refinement I'd like to make to the macro is in this block: #(if (or ;; append to this list if you get the warning: ;; Ignoring grob for slur: grob. avoid-slur not set? (equal? $top-grob Fingering) (equal? $top-grob Accidental) ) 'stencil 'avoid-slur) = ##f The reason it's there is because some grobs (like Staff.Clef and Staff.TimeSignature) by default have the 'avoid-slur property set to 'inside, which means the slur will be forced away, potentially defeating the whole purpose of the macro. At the same time, some other grobs (like Fingering and Staff.Accidental) will trigger a warning if you try to set 'avoid-slur to #f. The only problem with testing which grobs trigger the warning is that an instance of each grob needs to be present in the score for the warning to be triggered. So the command \override Fingering #'avoid-slur = ##f will trigger the warning only if there's actually a fingering in the score following the command. Does anyone know an easier way to find which grobs trigger this warning? Then I can incorporate it into the macro and save a little frustration for future users. Thanks. - Mark ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
hiding portions of slurs/ties around specific objects
Perhaps it was a coincidence that both Kieren and Maestraccio requested slur-hiding solutions recently: http://lists.gnu.org/archive/html/bug-lilypond/2009-03/msg00106.html http://lists.gnu.org/archive/html/lilypond-user/2009-04/msg00153.html I tried to solve both individually, but then realized that a generic solution was best, so here it is. The name is not very poetic though. Thanks, Neil and Patrick, for your coding help and suggestions. Questions and comments are welcome. If anyone wants to add it to the LSR, that's fine by me. Change the function name too, if you want, I couldn't think of anything better. Happy to help. - Mark \version 2.13.0 #(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 #(if (or ;; append to this list if you get the warning: ;; Ignoring grob for slur: grob. avoid-slur not set? (equal? $top-grob Fingering) (equal? $top-grob Accidental) ) 'stencil '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 #})) %% EXAMPLE %% %{ \version 2.13.0 \pointAndClickOff \relative { \repeat volta 2 { %% syntax: \hideCurvesFrom [grob] [x-padding] [y-padding] %% See comment above if you get the warning message: %% Ignoring grob for slur: grob. avoid-slur not set? % always call \hideCurvesFrom before the curve starts: \hideCurvesFrom #'Fingering #'(0.3 . 0.3) #'(0 . 0) \hideCurvesFrom #'Staff.KeySignature #'(0.3 . 0.3) #'(0 . 0) \hideCurvesFrom #'Staff.TimeSignature #'(0.3 . 0.3) #'(0 . 0) % a negative padding value can prevent whiteout near an edge: \hideCurvesFrom #'Staff.Clef #'(0.3 . 0.3) #'(0 . -0.5) \clef bass \once \override TextScript #'extra-offset = #'(-8 . 0) e,2.\(^\markup \fontsize #-1 \italic {tacet la \concat {1 \super \lower #0.5 ma} volta:} d4( | \clef treble \key g \major c''4)^2 c2 b4~ | \time 3/4 b2\) % updating a previously entered command: \hideCurvesFrom #'Staff.Clef #'(0.3 . 0.3) #'(0 . 0) fis4( | \clef bass \time