]> git.donarmstrong.com Git - lilypond.git/blob - input/test/polymetric-differing-notes.ly
88b88fc291074e2e7563a4b65ff5eb5c8ae88538
[lilypond.git] / input / test / polymetric-differing-notes.ly
1 \version "2.1.26"
2
3 \header{ texidoc="
4
5 @cindex polymetric music
6
7 @cindex scaling durations
8
9 It is possible to have multiple time signatures, each one in an own staffs, 
10 at the same time, and have even a proper vertical alignment of the different 
11 durations.  This is done, firstly, by setting a common time signature for
12 each staff but replacing it manually using @code{timeSignatureFraction} to 
13 the desired fraction, and secondly, by scaling the printed durations to
14 the actual, polymetric durations.
15
16 In this example, music with the time signatures of 3/4, 9/8 and 10/8 are
17 used in parallel. In the second staff, shown durations are multiplied by 
18 2/3, so that 2/3 * 9/8 = 3/4, and in the third staff, shown durations are 
19 multiplied by 3/5, so that 3/5 * 10/8 = 3/4.
20
21 "
22
23 }
24
25
26 #(define (scale-one-music m fraction)
27   "Maybe we should just export Music::compress to Scheme?"
28   (let*
29    ((dur (ly:music-property m 'duration)))
30    
31    (if (ly:duration? dur)
32     (let*
33      ((l (ly:duration-log dur))
34       (d (ly:duration-dot-count dur))
35       (factor (ly:duration-factor dur)))
36
37       (ly:music-set-property! m 'duration
38                             (ly:make-duration l d
39                              (* (car fraction) (car factor))
40                              (* (cdr fraction) (cdr factor))))))
41    
42    m))
43
44 #(define (scale-music-function fraction)
45   (lambda (x) 
46    (music-map (lambda (y) (scale-one-music y fraction)) x)))
47
48
49
50 \score {
51     \notes \relative c'  <<
52         \new Staff {
53             \time 3/4
54             c4 c c | c c c |
55         }
56         \new Staff {
57             \time 3/4
58             \set Staff.timeSignatureFraction = #'(9 . 8)
59             \apply #display-music \apply #(scale-music-function '(2 . 3))
60               \repeat unfold 6 { c8[ c c] }
61         }
62         
63         \new Staff {
64             \time 3/4
65             \set Staff.timeSignatureFraction = #'(10 . 8)
66             \apply #display-music \apply #(scale-music-function '(3 . 5))
67               { \repeat unfold 2 { c8[ c c] }
68                 \repeat unfold 2 { c8[  c] }
69                 |  c4. c4. \times 2/3 { c8 c c } c4  }
70         }
71         >>
72         \paper { raggedright = ##t }
73 }