]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/lily-in-scheme.ly
* ly/a4-init.ly (vsize): remove papersize init files.
[lilypond.git] / input / regression / lily-in-scheme.ly
1 \header { texidoc = "LilyPond syntax can be used inside scheme to
2     build music expressions, with the @code{#@{ ... #@}} syntax.
3     Scheme forms can be introduced inside these blocks by escaping
4     them with a @code{$}, both in a LilyPond context or in a Scheme
5     context.
6
7 In this example, the @code{\withpaddingA}, @code{\withpaddingB} and
8 @code{\withpaddingC} music functions set different kinds of padding on
9 the @code{TextScript} grob.
10
11 "
12           
13       }
14
15 \version "2.3.16"
16 \paper { raggedright = ##t }
17
18 withPaddingA = #(def-music-function (location padding music) (number? ly:music?)
19                      #{ \override TextScript #'padding = #$padding
20                         $music 
21                         \revert TextScript #'padding #})
22
23 withPaddingB = #(def-music-function (location padding music) (number? ly:music?)
24                      #{ \override TextScript #'padding = #$(* padding 2)
25                         $music 
26                         \revert TextScript #'padding #})
27
28 withPaddingC = #(def-music-function (location padding music) (number? ly:music?)
29                      #{ \override TextScript #'padding = #(+ 1 $(* padding 2))
30                         $music 
31                         \revert TextScript #'padding #})
32
33 \score {
34     \notemode {
35         c'^"1"
36         \withPaddingA #2
37         { c'^"2" c'^"3"}
38         c'^"4"
39         \withPaddingB #2
40         { c'^"5" c'^"6"}
41         c'^"7"
42         \withPaddingC #2
43         { c'^"8" c'^"9"}
44         c'^"10"
45     }
46 }