\version "2.14.1"
\paper {
line-width = 120
indent = 0
}
% http://codereview.appspot.com/2220041/patch/12001/13007
% Charset definitions (completing standard guile defs)
#(define-public (char-punctuation? ch)
(char-set-contains? char-set:punctuation ch))
#(define-public char-set:dynamics
(char-set #\f #\m #\p #\r #\s #\z))
% http://git.savannah.gnu.org/cgit/opus-libre.git/tree/bin/markup-commands.scm
% by Valentin Villenave
#(define-markup-command (dynamic-string layout props str) (string?)
#:category font
"
@cindex dynamics, composite
@cindex dynamics, mixed with text
Print a string using the dynamic font only when appropriate.
Words may be separated with @code{_}; dynamic-style characters
will only be used in words that contain no other letter than
@b{f}, @b{m}, @b{p}, @b{r}, @b{s} and @b{z}, and punctuation
marks. Regular spaces are allowed inside words.
@lilypond[verbatim,quote]
\\markup {
\\dynamic-string #\"mp,_quasi_mf_ma più dolce.\"
}
@end lilypond"
(let ((composite-chars (char-set-union
char-set:dynamics
char-set:whitespace
char-set:punctuation))
(split (lambda (s) (string-index s #\_ )))
(str-list '())
(dyn-markup (lambda (s)
(make-whiteout-markup ;;-a
(make-dynamic-markup s)))) ;;-a
;(make-dynamic-markup s))) ;;+b
(text-markup (lambda (s)
(make-whiteout-markup
(make-normal-text-markup
(make-italic-markup s))))))
(do ((current-str (string-append str "_")))
((not (split current-str)))
(begin
(set! str-list
(append str-list (list
(string-take current-str (split current-str)))))
(set! current-str
(string-drop current-str (+ (split current-str) 1)))))
(interpret-markup layout props
(make-line-markup
(map (lambda (word)
(if (string-every composite-chars word)
(if (string-every char-set:dynamics word)
(dyn-markup word)
(let ((word-lst (string->list word)))
(make-concat-markup
(map (lambda (ch)
(let ((print-ch (string ch)))
(if (char-punctuation? ch)
(text-markup print-ch)
(dyn-markup print-ch))))
word-lst))))
(text-markup word)))
str-list)))))
% Additionals by Harm
#(define my-dyn-alist '(
("pptop" . "pp_<_p_>_pp_etc . . .")
("ffdolcef" . "ff_dolce >_f")
("pleggierodolce" . "p,_leggiero e dolce")
("dolcecantabile" . "dolce e cantabile")
("fcantabile" . "f,_ma cantabile")
("pquasieco" . "p,_quasi eco")
("subitoff" . "subito_ff")
("mpquasimf" . "mp_,quasi_mf_ma più dolce.")
("fffmarcato" . "fff_marcato sempre")
("madolcecant" . "ma dolce e cantabile")
))
#(define (assocDynAlist name)
"Aus my-dyn-alist wird der 2. Eintrag einer Zeile ausgelesen!
Die Zeile wir via name angesteuert!"
(assoc-ref my-dyn-alist name))
#(define-markup-command (newDyn layout props name)(string?)
"newDyn kann den 2. Eintrag einer Zeile aus my-dyn-alist mit dynamic-string verarbeiten!
Die Zeile wir via name angesteuert!"
(interpret-markup
layout props (markup #:dynamic-string (assocDynAlist name))))
% nach: http://codereview.appspot.com/2220041/patch/12001/13005
#(define (makeAlistDynamicScript name)
"Mittels alist-Aufruf via newDyn wird eine neues left-aligned custom-Dynamic möglich"
(make-music 'AbsoluteDynamicEvent
'tweaks
(list (cons 'X-offset -1.5))
'text
(markup #:newDyn name)))
#(define (makeDynamicScript text)
"Eine neues left-aligned custom-Dynamic mit beliebigem Text (in der für dynamic-string
nötigen Syntax) wird möglich"
(make-music 'AbsoluteDynamicEvent
'tweaks
(list (cons 'X-offset -1.5))
'text
(markup #:dynamic-string text)))
mpquasimf = #(makeAlistDynamicScript "mpquasimf")
dffs = #(makeDynamicScript "Das-soll_ff_sein!!")
myLeftDynamic =
#(define-music-function (parser location name)(string?)
(make-music
'AbsoluteDynamicEvent
'tweaks
;; calculate centering for text
(list (cons 'X-offset -1.5))
'text
(markup #:newDyn name
)))
myDynamic =
#(define-music-function (parser location name align)(string? integer?)
"Diese Funktion erstellt mittels alist-Aufruf via newDyn neue custom-Dynamics. Man hat
die Möglichkeit linksbündig (#'-1) oder zentriert (#'0) auszuwählen (alle Zahlen >0 führen zur
zentrierter Ausgabe).
Syntax: -\\myDynamic <name> #'-1"
(make-music
'AbsoluteDynamicEvent
'tweaks
;; calculate centering for text
(cond
((< align 0) (list (cons 'X-offset -1.5)))
;(else (list (cons 'X-offset 0 )))
)
'text
(markup #:newDyn name
)))
%------------------------------ Test -------------------------------------------
\markup { \fill-line { \bold "Dynamic-Scripts" \null} }
\relative c' {
s1 a'\mpquasimf \break
s b\dffs
}
\markup \fill-line{\column {\vspace #2 \bold "myDynamic und myLeftDynamic" } \null}
\relative c''
{
\override Staff.TimeSignature #'stencil = ##f
a4 a bes-\myDynamic "pptop" #'-1 a|
a a bes-\myDynamic "subitoff" #'-1 a |
a bes a a |\break
a a bes-\myDynamic "ffdolcef" #'0 a |
a bes-\myLeftDynamic "ffdolcef" a a |
a a a a |\break
a a bes-\myDynamic "pleggierodolce" #'-1 a |
a a a a |
a a a a |\break
a a bes-\myDynamic "dolcecantabile" #'0 a |
a a a a|
a a a a |\break
a a bes-\myDynamic "fcantabile" #'-1 a |
a a a a |
a a a a |
}
\markup \fill-line{\column {\vspace #2 \bold "markup" } \null}
\relative c'' {
\override TextScript #'staff-padding = #1
%\textLengthOn
gis1_\markup { \newDyn #"mpquasimf"} a
gis a_\markup { \translate #'(1.3 . 0) \right-align \newDyn #"subitoff"} \break
gis a_\markup { \center-align \newDyn #"pleggierodolce"}
gis_\markup { \newDyn #"dolcecantabile"} a\break
gis_\markup { \newDyn #"fcantabile"} a
gis_\markup { \newDyn #"pquasieco"} a\break
gis_\markup { \left-column \fontsize #'-1 {\newDyn #"pptop" \newDyn #"madolcecant" }}a
gis_\markup { \newDyn #"fffmarcato"} a
}