[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Hairpin direction
From: |
Thomas Morley |
Subject: |
Re: Hairpin direction |
Date: |
Sat, 5 Oct 2013 23:35:48 +0200 |
2013/10/5 Thomas Morley <address@hidden>:
[...]
> Though, you'll notice that the Hairpins are shortened by the DynamicText.
> Til now I've found no way around it.
Hi again,
the code below seems to work:
\version "2.17.27"
%% A helper
#(define (look-up-for-parent name-symbol axis grob)
"
Return the parent of @var{grob}, specified by it's @var{name-symbol} in
axis @var{axis}.
If not found, look up for the next parent.
"
(let* ((parent (ly:grob-parent grob axis))
(grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))))
(cond
((not (ly:grob? parent))
(ly:error
(_"Perhaps typing error for \"~a\" or \"~a\" is not in the parent-tree.")
name-symbol name-symbol))
((not (equal? name-symbol (grob-name parent)))
(look-up-for-parent name-symbol axis parent))
(else parent))))
%% As the name implies.
#(define (set-spanner-bounds-to-note-column! grob)
(let* ((grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
(left-bound (ly:spanner-bound grob LEFT))
(left-bound-parent
(if (not (eq? (grob-name left-bound) 'NoteColumn))
(look-up-for-parent 'NoteColumn X left-bound)
left-bound))
(right-bound (ly:spanner-bound grob RIGHT))
(right-bound-parent
(if (not (eq? (grob-name right-bound) 'NoteColumn))
(look-up-for-parent 'NoteColumn X right-bound)
right-bound)))
;(display "\n\tleft-bound \t\t")(write left-bound)
;(display "\n\tleft-bound-parent \t")(write left-bound-parent)
;(display "\n\tright-bound \t\t")(write right-bound)
;(display "\n\tright-bound-parent \t")(write right-bound-parent)
;(newline)
(ly:spanner-set-bound! grob LEFT left-bound-parent)
(ly:spanner-set-bound! grob RIGHT right-bound-parent)))
customDynamics =
#(define-music-function (parser location music)(ly:music?)
"
Print DynamicText below.
Print spanned Dynamics above.
"
(music-map
(lambda (m)
(if (music-is-of-type? m 'note-event)
(let ((art (ly:music-property m 'articulations)))
(for-each
(lambda (n)
(cond ((music-is-of-type? n 'absolute-dynamic-event)
(ly:music-set-property! n 'direction -1))
((music-is-of-type? n 'span-dynamic-event)
(ly:music-set-property! n 'direction 1))
(else n)))
art)
m)
m))
music))
hairpin-bound-to-note-column =
\override Hairpin #'before-line-breaking =
#set-spanner-bounds-to-note-column!
%%%%%%%%%%%%%%%%%%%%
% EXAMPLE
%%%%%%%%%%%%%%%%%%%%
\layout {
\hairpin-bound-to-note-column
}
\customDynamics
\relative c' {
c1\f\> cis2 d\p\!
\repeat volta 2 {
c1\mf\> cis2 d\mp\!
}
\alternative {
{ c1\pp\< cis2 d\ff\! }
{ c1\ppp\< cis2 d\fff\! }
}
}
HTH,
Harm