]> git.donarmstrong.com Git - lilypond.git/blob - input/test/music-box.ly
* buildscripts/mf-to-table.py (base): break table every three
[lilypond.git] / input / test / music-box.ly
1 \version "1.7.18"
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.7.18"
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" s1*32 \enda }
86     \context Staff=down { \clef "F" s1*32 < \context Voice=vup \endb
87                                              \context Voice=vdwn \endc
88                         > }
89     { \apply #transform {\pat {c e g c' e' }
90                          \pat {c d a d' f' }
91                          \pat {h, d g d' f' }
92                          \pat {c e g c' e' }
93                      }
94       
95       %{
96       %Etc.
97
98       %we get the idea now.
99
100
101       
102                          \pat {c e a e' a' }
103                          \pat {c d fis a d'  }
104                          \pat {h, d g d' g' }
105                          \pat {h, c e g c' }
106                          \pat {a, c e g c'  }
107                          \pat {d, a, d fis c' }
108                          \pat {g, h, d g h }
109                          \pat {g, b, e g cis'  }
110                          \pat {f, a, d a d' }
111                          \pat {f, as, d f h }
112                          \pat {e, g, c g c' }
113                          \pat {e, f, a, c f }
114                          \pat {d, f, a, c f }
115
116                          \pat {g,, d, g, h, f }
117                          \pat {c, e, g, c e }
118                          \pat {c, g, b, c e }
119                          \pat {f,, f, a, c e  }
120                          \pat {fis,, c, a, c es }
121                          \pat {as,, f, h, c d }
122                          \pat {g,, f, g, h, d }
123                          \pat {g,, e, g, c e }
124                          \pat {g,, d, g, c f }
125                          \pat {g,, d, g, h, f }
126                          \pat {g,, es, a, c fis }
127                          \pat {g,, e, g, c g }
128                          \pat {g,, d, g, c f }
129                          \pat {g,, d, g, h, f }
130                          \pat {c,, c, g, b, e }
131                         %}
132     }
133   >
134   \paper {
135     \translator {
136       \PianoStaffContext
137       VerticalAlignment \override #'forced-distance = #10
138     }
139
140     linewidth = 18.0 \cm
141   }
142   \midi {
143       \tempo 4 = 80
144   }
145 }
146