LilyPond Beginnershandleiding
LilyPond Beginnershandleiding
LilyPond Beginnershandleiding
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Hoofdstuk 3: Fundamentele concepten 85<br />
}<br />
<br />
<br />
<br />
dolce<br />
hi there!<br />
<br />
<br />
<br />
<br />
f 2ndp <br />
These variables are obviously useful for saving typing. But they’re worth considering even if<br />
you only use them once – they reduce complexity. Let’s look at the previous example without<br />
any variables. It’s a lot harder to read, especially the last line.<br />
violin = \relative c'' {<br />
\repeat volta 2 {<br />
c4._\markup { \italic \bold dolce } b8 a8 g a b |<br />
\once \override TextScript.padding = #5.0<br />
c4.^"hi there!" d8 e' f g d |<br />
c,4.\markup {<br />
\dynamic f \italic \small { 2nd } \hspace #0.1 \dynamic p<br />
}<br />
b8 c4 c-. |<br />
}<br />
}<br />
So far we’ve seen static substitution – when <strong>LilyPond</strong> sees \padText, it replaces it with the<br />
stuff that we’ve defined it to be (ie the stuff to the right of padtext=).<br />
<strong>LilyPond</strong> can handle non-static substitution, too (you can think of these as functions).<br />
padText =<br />
#(define-music-function<br />
(parser location padding)<br />
(number?)<br />
#{<br />
\once \override TextScript.padding = #padding<br />
#})<br />
\relative c''' {<br />
c4^"piu mosso" b a b |<br />
\padText #1.8<br />
c4^"piu mosso" d e f |<br />
\padText #2.6<br />
c4^"piu mosso" fis a g |<br />
}<br />
<br />
<br />
<br />
<br />
<br />
<br />
piu mosso<br />
<br />
<br />
<br />
piu mosso<br />
<br />
<br />
<br />
piu mosso<br />
Using variables is also a good way to reduce work if the <strong>LilyPond</strong> input syntax changes (see<br />
Sectie “Updating files with convert-ly” in Gebruiks handleiding). If you have a single definition<br />
(such as \dolce) for all your input files (see Sectie 4.6.3 [Style sheets], pagina 137), then if<br />
the syntax changes, you only need to update your single \dolce definition, instead of making<br />
changes throughout every ‘.ly’ file.