Commit 1536c55c authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Add make-attr-dynamic-script to create dynamics with text before/after the dynamic

parent 46dd70d1
......@@ -1104,33 +1104,72 @@ hairpinOffset = #(define-music-function (parser location posY) (number?)
\once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
#})
#(define ((line-break-offset before after) grob)
(let* ((orig (ly:grob-original grob))
; All siblings if line-broken:
(siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
(if (>= (length siblings) 2)
; We have been line-broken
(if (eq? (car (last-pair siblings)) grob)
; Last sibling:
(ly:grob-set-property! grob 'Y-offset after)
; Others get the before value:
(ly:grob-set-property! grob 'Y-offset before)
)
)
)
)
% #(define ((line-break-offset before after) grob)
% (let* ((orig (ly:grob-original grob))
% ; All siblings if line-broken:
% (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
% (if (>= (length siblings) 2)
% ; We have been line-broken
% (if (eq? (car (last-pair siblings)) grob)
% ; Last sibling:
% (ly:grob-set-property! grob 'Y-offset after)
% ; Others get the before value:
% (ly:grob-set-property! grob 'Y-offset before)
% )
% )
% )
% )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Custom dynamic commands (with optional text before/after the dynamic)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% calculate x-alignment based on attribute text + dynamic text
% this has to be a markup-command to get stencil-extent based on (interpret-markup layout props ...)
#(define-markup-command (center-dyn layout props pre-text dyn post-text)(markup? string? markup?)
"x-align on center of dynamic with pre- and post-texts"
(let* (
(pre-stencil (interpret-markup layout props (markup #:normal-text #:italic pre-text )))
(post-stencil (interpret-markup layout props (markup #:normal-text #:italic post-text)))
(dyn-stencil (interpret-markup layout props (markup #:dynamic dyn)))
(pre-x (interval-length (ly:stencil-extent pre-stencil X)))
(dyn-x (interval-length (ly:stencil-extent dyn-stencil X)))
(post-x (interval-length (ly:stencil-extent post-stencil X)))
(x-align
(* (-
(/ (+ pre-x (/ dyn-x 2)) (+ pre-x dyn-x post-x) )
0.5) 2)
)
)
(interpret-markup layout props (markup #:halign x-align #:line (#:normal-text #:italic pre-text #:dynamic dyn #:normal-text #:italic post-text)))
))
% define a 'new' attributed dynamic script
#(define (make-attr-dynamic-script pre dyn post)
(let ((dynamic (make-dynamic-script (markup #:center-dyn pre dyn post))))
(ly:music-set-property! dynamic 'tweaks (acons 'X-offset 0 (ly:music-property dynamic 'tweaks)))
dynamic))
#(define (make-whiteout-attr-dynamic-script pre dyn post)
(let ((dynamic (make-dynamic-script (markup #:whiteout #:center-dyn pre dyn post))))
(ly:music-set-property! dynamic 'tweaks (acons 'X-offset 0 (ly:music-property dynamic 'tweaks)))
dynamic))
rf = #(make-dynamic-script "rf")
ffz = #(make-dynamic-script "ffz")
pf = #(make-dynamic-script "pf")
sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
'(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
sempp = #(make-attr-dynamic-script "sempre" "pp" "")
pdolce = #(make-attr-dynamic-script "" "p" "dolce")
ppdolce = #(make-attr-dynamic-script "" "pp" "dolce")
dolce = -\tweak #'X-offset #0 #(make-dynamic-script (markup #:halign -0.25 #:whiteout #:pad-markup 0.5 #:normal-text #:italic "dolce"))
sfpdolce = #(make-attr-dynamic-script "" "sfp" "dolce")
parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")")))
parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")")))
pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce")))
ppdolce = #(make-dynamic-script (markup #:line(#:dynamic "pp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce")))
dolce = #(make-dynamic-script (markup #:line(#:concat (#:normal-text #:italic "do" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "lce"))))
sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
bracketmf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "mf" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
bracketmp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "mp" #:normal-text #:fontsize 2 "]"))))
......@@ -1141,6 +1180,12 @@ whiteoutpp = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic
whiteoutf = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic "f"))
whiteoutff = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic "ff"))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sim = ^\markup{\italic "sim."}
%%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment