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:music-property music 'elements))
12 (n (ly:music-name music))
14 (if (not (equal? n "Sequential_music"))
15 (ly:warn "transform needs sequential music!")
17 (let recurse ((elts es))
18 (if (not (equal? elts '()))
20 ((trans (ly:music-property (cadr elts) 'elements)) (car elts))
21 (set-cdr! elts (cddr elts))
32 #(define ((trans pitches) music)
33 (let* ((es (ly:music-property music 'elements))
34 (e (ly:music-property music 'element))
35 (p (ly:music-property music 'pitch)))
38 (ly:music-set-property!
40 (map (trans pitches) es)))
43 (ly:music-set-property!
48 (let* ((o (ly:pitch-octave p))
49 (n (ly:pitch-notename p))
51 (pes (ly:music-property (list-ref pitches i) 'elements))
52 (pnew (ly:music-property (car pes) 'pitch))
54 (ly:music-set-property! music 'pitch pnew)
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 }
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 }
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' }
105 \pat {d, a, d fis c' }
107 \pat {g, b, e g cis' }
114 \pat {g,, d, g, h, f }
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 }
135 \override VerticalAlignment #'forced-distance = #10