]> git.donarmstrong.com Git - lilypond.git/blob - input/test/music-box.ly
Massive changes - see ChangeLog.
[lilypond.git] / input / test / music-box.ly
1 \version "1.9.0"
2 \include "deutsch.ly"
3 % possible rename to scheme- something.  -gp
4 % TODO: ask if it needs to have so many empty bars in the middle.  -gp
5 \header{ texidoc = "@cindex Scheme Music Box
6 This example shows prelude in C major of WTK1, but coded
7 using Scheme functions to avoid typing work. " }
8
9
10 #(define (transform music)
11   (let* ((es (ly:get-mus-property music 'elements))
12          (n  (ly:music-name music))
13         )
14    (if (not (equal? n "Sequential_music"))
15      (ly:warn "transform needs sequential music!")
16      (begin
17       (let recurse ((elts es))
18        (if (not (equal? elts '()))
19          (begin
20            ((trans (ly:get-mus-property (cadr elts) 'elements)) (car elts))
21            (set-cdr! elts (cddr elts))
22            (recurse (cdr elts))
23          )
24        )
25       )
26      )
27    )
28    music
29   )
30  )
31
32 #(define ((trans pitches) music)
33   (let* ((es (ly:get-mus-property music 'elements))
34          (e (ly:get-mus-property music 'element))
35          (p (ly:get-mus-property music 'pitch)))
36
37     (if (pair? es)
38         (ly:set-mus-property!
39          music 'elements
40          (map (trans pitches) es)))
41
42     (if (ly:music? e)
43         (ly:set-mus-property!
44          music 'element
45          ((trans pitches) e)))
46
47     (if (ly:pitch? p)
48        (let* ((o (ly:pitch-octave p))
49               (n (ly:pitch-notename p))
50               (i (+ (* 7 o) n))
51               (pes (ly:get-mus-property (list-ref pitches i) 'elements))
52               (pnew (ly:get-mus-property (car pes) 'pitch))
53              )
54           (ly:set-mus-property! music 'pitch pnew)
55         )
56     )
57     music
58   )
59  )
60
61
62
63
64
65 \version "1.9.0"
66
67 pat = \notes \transpose c c' \repeat unfold 2 {
68   < { \context Staff=up {r8 e16 f g e f g } }
69     { \context Staff=down <
70       \context Voice=vup  { \stemUp \tieUp r16 d8.~d4 }
71       \context Voice=vdwn { \stemDown  c2 }
72     > }
73   >
74 }
75
76 enda = \notes { r8 f,16 a, c f c a, \stemUp c \translator Staff = down
77       a, f, a, f, d, f, d, \translator Staff = up \stemBoth
78       r8 g16 h d' f' d' h d' h g h d f e-\prall d <<e g c'>>1^\fermata \bar "|."
79 }
80 endb = \notes {\stemUp \tieUp r16 c,8.~c,4~c,2 r16 h,,8.~h,,4~h,,2 c,1 \bar "|."}
81 endc = \notes {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata }
82
83 \score {
84   \notes \transpose c c' \context PianoStaff <
85     \context Staff=up   { \clef "G"  }
86     \context Staff=down { \clef "F" }
87     { \apply #transform {\pat {c e g c' e' }
88                          \pat {c d a d' f' }
89                          \pat {h, d g d' f' }
90                          \pat {c e g c' e' }
91                      }
92       
93       %{
94       %Etc.
95
96       %we get the idea now.
97
98
99       
100                          \pat {c e a e' a' }
101                          \pat {c d fis a d'  }
102                          \pat {h, d g d' g' }
103                          \pat {h, c e g c' }
104                          \pat {a, c e g c'  }
105                          \pat {d, a, d fis c' }
106                          \pat {g, h, d g h }
107                          \pat {g, b, e g cis'  }
108                          \pat {f, a, d a d' }
109                          \pat {f, as, d f h }
110                          \pat {e, g, c g c' }
111                          \pat {e, f, a, c f }
112                          \pat {d, f, a, c f }
113
114                          \pat {g,, d, g, h, f }
115                          \pat {c, e, g, c e }
116                          \pat {c, g, b, c e }
117                          \pat {f,, f, a, c e  }
118                          \pat {fis,, c, a, c es }
119                          \pat {as,, f, h, c d }
120                          \pat {g,, f, g, h, d }
121                          \pat {g,, e, g, c e }
122                          \pat {g,, d, g, c f }
123                          \pat {g,, d, g, h, f }
124                          \pat {g,, es, a, c fis }
125                          \pat {g,, e, g, c g }
126                          \pat {g,, d, g, c f }
127                          \pat {g,, d, g, h, f }
128                          \pat {c,, c, g, b, e }
129                         %}
130     }
131   >
132   \paper {
133     \translator {
134       \PianoStaffContext
135       VerticalAlignment \override #'forced-distance = #10
136     }
137
138     linewidth = 18.0 \cm
139   }
140   \midi {
141       \tempo 4 = 80
142   }
143 }
144