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