release commit
[lilypond.git] / input / test / music-box.ly
blobcd4da197deec541be2b6be55fdd7c53e0aeb2feb
1 \version "2.1.7"
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. " }
10 #(define (transform music)
11 (let* ((es (ly:get-mus-property music 'elements))
12 (n (ly:music-name music))
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))
28 music
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)))
37 (if (pair? es)
38 (ly:set-mus-property!
39 music 'elements
40 (map (trans pitches) es)))
42 (if (ly:music? e)
43 (ly:set-mus-property!
44 music 'element
45 ((trans pitches) e)))
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))
54 (ly:set-mus-property! music 'pitch pnew)
57 music
65 \version "2.1.7"
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 >> }
76 enda = \notes { r8 f,16 a, c f c a, \stemUp c \change Staff = down
77 a, f, a, f, d, f, d, \change 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 "|."
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 }
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' }
94 %Etc.
96 %we get the idea now.
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 }
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 }
132 \paper {
133 \translator {
134 \PianoStaffContext
135 VerticalAlignment \override #'forced-distance = #10
138 linewidth = 18.0 \cm
140 \midi {
141 \tempo 4 = 80