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