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