]> git.donarmstrong.com Git - lilypond.git/blob - input/test/polymetric-differing-notes.ly
47898be9fefe15435516a36a958124b2078cfa4e
[lilypond.git] / input / test / polymetric-differing-notes.ly
1 #(ly:set-option 'old-relative)
2 \version "1.9.2"
3
4 \header{ texidoc="
5
6 @cindex polymetric music
7
8 @cindex scaling durations
9
10 You can have multiple time signatures occuring at the same time, with
11 different durations aligned.  This is done by 1. compressing one of
12 the lines, analogous to \times, but without the bracket, and
13 2. manually setting timeSignatureFraction to the desired fraction.
14
15 This example puts 3/4, 9/8 and 10/8 in parallel. The last staff shows
16 what happens on the inside: a 3/4 time signature is combined with a
17 3/5 tuplet yielding the equivalent of a 10/8.
18
19 "
20
21 }
22
23
24 #(define (scale-one-music m fraction)
25   "Maybe we should just export Music::compress to Scheme?"
26   (let*
27    ((dur (ly:get-mus-property m 'duration)))
28    
29    (if (ly:duration? dur)
30     (let*
31      ((l (ly:duration-log dur))
32       (d (ly:duration-dot-count dur))
33       (factor (ly:duration-factor dur)))
34
35       (ly:set-mus-property! m 'duration
36                             (ly:make-duration l d
37                              (* (car fraction) (car factor))
38                              (* (cdr fraction) (cdr factor))))))
39    
40    m))
41
42 #(define (scale-music-function fraction)
43   (lambda (x) 
44    (music-map (lambda (y) (scale-one-music y fraction)) x)))
45
46
47
48 \score {
49     \notes \relative c'  <
50         \new Staff {
51             \time 3/4
52             c4 c c | c c c |
53         }
54         \new Staff {
55             \time 3/4
56             \property Staff.timeSignatureFraction= #'(9 . 8)
57             \apply #display-music \apply #(scale-music-function '(2 . 3))
58               \repeat unfold 6 { c8[ c c] }
59         }
60         
61         \new Staff {
62             \time 3/4
63             \property Staff.timeSignatureFraction= #'(10 . 8)
64             \apply #display-music \apply #(scale-music-function '(3 . 5))
65               { \repeat unfold 2 { c8[ c c] }
66                 \repeat unfold 2 { c8[  c] }
67                 |  c4. c4. \times 2/3 { c8 c c } c4  }
68         }
69         >
70         \paper { raggedright = ##t }
71 }