2 \sourcefilename "music-box.ly"
5 % possible rename to scheme- something. -gp
6 % TODO: ask if it needs to have so many empty bars in the middle. -gp
7 \header{ texidoc = "@cindex Scheme Music Box
8 This example shows prelude in C major of WTK1, but coded
9 using Scheme functions to avoid typing work. " }
12 #(define (transform music)
13 (let* ((es (ly:music-property music 'elements))
14 (n (ly:music-property music 'name)))
15 (if (not (equal? n 'SequentialMusic))
16 (ly:warning "transform needs SequentialMusic, got ~a" n)
18 (let recurse ((elts es))
19 (if (not (equal? elts '()))
21 ((trans (ly:music-property (cadr elts) 'elements)) (car elts))
22 (set-cdr! elts (cddr elts))
28 #(define ((trans pitches) music)
29 (let* ((es (ly:music-property music 'elements))
30 (e (ly:music-property music 'element))
31 (p (ly:music-property music 'pitch)))
34 (ly:music-set-property!
36 (map (trans pitches) es)))
39 (ly:music-set-property!
44 (let* ((o (ly:pitch-octave p))
45 (n (ly:pitch-notename p))
47 (pes (ly:music-property (list-ref pitches i) 'elements))
48 (pnew (ly:music-property (car pes) 'pitch))
50 (ly:music-set-property! music 'pitch pnew)
55 pat = \transpose c c' \repeat unfold 2 {
56 << { \context Staff = "up" {r8 e16 f g e f g } }
57 { \context Staff = "down" <<
58 \context Voice = "vup" { \stemUp \tieUp r16 d8.~d4 }
59 \context Voice = "vdwn" { \stemDown c2 }
64 enda = { r8 f,16 a, c f c a, \stemUp c \change Staff = down
65 a, f, a, f, d, f, d, \change Staff = up \stemNeutral
66 r8 g16 h d' f' d' h d' h g h d f e\prall d <e g c'>1^\fermata \bar "|."
68 endb = {\stemUp \tieUp r16 c,8.~c,4~c,2 r16 h,,8.~h,,4~h,,2 c,1 \bar "|."}
69 endc = {\stemDown \tieDown c,,2~c,, c,,~c,, c,,1_\fermata }
73 #(define-music-function (parser location patterns) (ly:music?)
78 \transpose c c' \context PianoStaff <<
79 \new Staff = "up" { \clef "G" }
80 \new Staff = "down" { \clef "F" }
100 \pat {d, a, d fis c' }
102 \pat {g, b, e g cis' }
109 \pat {g,, d, g, h, f }
112 \pat {f,, f, a, c e }
113 \pat {fis,, c, a, c es }
114 \pat {as,, f, h, c d }
115 \pat {g,, f, g, h, d }
116 \pat {g,, e, g, c e }
117 \pat {g,, d, g, c f }
118 \pat {g,, d, g, h, f }
119 \pat {g,, es, a, c fis }
120 \pat {g,, e, g, c g }
121 \pat {g,, d, g, c f }
122 \pat {g,, d, g, h, f }
123 \pat {c,, c, g, b, e }
131 \override VerticalAlignment #'forced-distance = #10
133 line-width = 18.0 \cm
140 tempoWholesPerMinute = #(ly:make-moment 80 4)