]> git.donarmstrong.com Git - lilypond.git/blob - input/test/music-box.ly
2ff6c639e43bf313a4be33ded6336f20e259047b
[lilypond.git] / input / test / music-box.ly
1
2 \header{
3 texidoc = "This example shows prelude in C major of WTK1, but coded
4 using Scheme functions to save typing work.
5 "
6
7
8
9   title =  "Preludium"
10   opus =   "BWV 846"
11   composer = "Johann Sebastian Bach (1685-1750)"
12   enteredby = "Rune Zedeler"
13   mutopiatitle = "Das Wohltemperierte Clavier I, Prelude 1 (c-major)"
14   mutopiacomposer = "J.S.Bach"
15   mutopiaopus = "BWV846"
16   mutopiainstrument = "Piano"
17   style = "baroque"
18   copyright = "Public Domain"
19   maintainer = "rz@daimi.au.dk"
20   lastupdated = "2001/mar/30"
21   tagline = "\\parbox{\hsize}{\\thefooter\\quad\\small \\\\This music is part of the Mutopia project, \\texttt{http://www.mutopiaproject.org/}\\\\It has been typeset and placed in the public domain by " + \maintainer + ".\\\\Unrestricted modification and redistribution is permitted and encouraged---copy this music and share it!}"
22 }
23
24 \include "deutsch.ly"
25
26 #(define (transform music)
27   (let* ((es (ly-get-mus-property music 'elements))
28          (n  (ly-music-name music))
29         )
30    (if (not (equal? n "Sequential_music"))
31      (ly-warn "transform needs sequential music!")
32      (begin
33       (let recurse ((elts es))
34        (if (not (equal? elts '()))
35          (begin
36            ((trans (ly-get-mus-property (cadr elts) 'elements)) (car elts))
37            (set-cdr! elts (cddr elts))
38            (recurse (cdr elts))
39          )
40        )
41       )
42      )
43    )
44    music
45   )
46  )
47
48 #(define ((trans pitches) music)
49   (let* ((es (ly-get-mus-property music 'elements))
50          (e (ly-get-mus-property music 'element))
51          (p (ly-get-mus-property music 'pitch))
52          (body (ly-get-mus-property music 'body))
53          (alts (ly-get-mus-property music 'alternatives)))
54
55     (if (pair? es)
56         (ly-set-mus-property
57          music 'elements
58          (map (trans pitches) es)))
59
60     (if (music? alts)
61         (ly-set-mus-property
62          music 'alternatives
63          ((trans pitches) alts)))
64
65     (if (music? body)
66         (ly-set-mus-property
67          music 'body
68          ((trans pitches) body)))
69
70     (if (music? e)
71         (ly-set-mus-property
72          music 'element
73          ((trans pitches) e)))
74
75     (if (pitch? p)
76        (let* ((o (pitch-octave p))
77               (n (pitch-notename p))
78               (i (+ (* 7 o) n))
79               (pes (ly-get-mus-property (list-ref pitches i) 'elements))
80               (pnew (ly-get-mus-property (car pes) 'pitch))
81              )
82           (ly-set-mus-property music 'pitch pnew)
83         )
84     )
85     music
86   )
87  )
88
89
90
91
92
93 \version "1.3.142"
94
95 pat = \notes \transpose c'' \repeat unfold 2 {
96   < { \context Staff=up {r8 e16 f g e f g } }
97     { \context Staff=down <
98       \context Voice=vup  { \stemUp \tieUp r16 d8.~d4 }
99       \context Voice=vdwn { \stemDown  c2 }
100     > }
101   >
102 }
103
104 enda = \notes { r8 f,16 a, c f c a, \stemUp c \translator Staff = down
105       a, f, a, f, d, f, d, \translator Staff = up \stemBoth
106       r8 g16 h d' f' d' h d' h g h d f e-\prall d <e1 g c'^\fermata> \bar "|."
107 }
108 endb = \notes {\stemUp \tieUp r16 c,8.~c,4~c,2 r16 h,,8.~h,,4~h,,2 c,1 \bar "|."}
109 endc = \notes {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata }
110
111 \score {
112   \notes \transpose c'' \context PianoStaff <
113     \context Staff=up   { \clef "G" s1*32 \enda }
114     \context Staff=down { \clef "F" s1*32 < \context Voice=vup \endb
115                                              \context Voice=vdwn \endc
116                         > }
117     { \apply #transform {\pat {c e g c' e' }
118                          \pat {c d a d' f' }
119                          \pat {h, d g d' f' }
120                          \pat {c e g c' e' }
121                          \pat {c e a e' a' }
122                          \pat {c d fis a d'  }
123                          \pat {h, d g d' g' }
124                          \pat {h, c e g c' }
125                          \pat {a, c e g c'  }
126                          \pat {d, a, d fis c' }
127                          \pat {g, h, d g h }
128                          \pat {g, b, e g cis'  }
129                          \pat {f, a, d a d' }
130                          \pat {f, as, d f h }
131                          \pat {e, g, c g c' }
132                          \pat {e, f, a, c f }
133                          \pat {d, f, a, c f }
134
135                          \pat {g,, d, g, h, f }
136                          \pat {c, e, g, c e }
137                          \pat {c, g, b, c e }
138                          \pat {f,, f, a, c e  }
139                          \pat {fis,, c, a, c es }
140                          \pat {as,, f, h, c d }
141                          \pat {g,, f, g, h, d }
142                          \pat {g,, e, g, c e }
143                          \pat {g,, d, g, c f }
144                          \pat {g,, d, g, h, f }
145                          \pat {g,, es, a, c fis }
146                          \pat {g,, e, g, c g }
147                          \pat {g,, d, g, c f }
148                          \pat {g,, d, g, h, f }
149                          \pat {c,, c, g, b, e }
150                         }
151     }
152   >
153   \paper {
154     \translator {
155       \PianoStaffContext
156       VerticalAlignment \override #'forced-distance = #10
157     }
158
159     linewidth = 18.0 \cm
160   }
161   \midi {
162       \tempo 4 = 80
163   }
164 }