]> git.donarmstrong.com Git - lilypond.git/blob - scm/music-functions.scm
release: 1.5.17
[lilypond.git] / scm / music-functions.scm
1
2 (define (denominator-tuplet-formatter mus)
3   (number->string (ly-get-mus-property mus 'denominator)))
4
5 (define (fraction-tuplet-formatter mus)
6   (string-append (number->string (ly-get-mus-property mus 'numerator))
7                  ":"
8                  (number->string (ly-get-mus-property mus 'denominator))
9                  ))
10
11 (define (unfold-repeats music)
12 "
13 [Rune Zedeler]
14
15 Han-Wen Nienhuys wrote:
16
17 > It shouldn't be hard to write a Scheme function to replace all repeats
18 > with unfold repeats.
19 [...]
20 > Left to the reader as an exercise.
21
22 With thanks to Han-Wen:
23
24
25 "
26   (let* ((es (ly-get-mus-property music 'elements))
27          (e (ly-get-mus-property music 'element))
28          (body (ly-get-mus-property music 'body))
29          (alts (ly-get-mus-property music 'alternatives))
30          (n  (ly-music-name music)))
31
32     (if (equal? n "Repeated_music")
33         (begin
34           (ly-set-mus-property
35            music 'length Repeated_music::unfolded_music_length)
36           (ly-set-mus-property
37            music 'iterator-ctor Unfolded_repeat_iterator::constructor)))
38
39     (if (pair? es)
40         (ly-set-mus-property
41          music 'elements
42          (map unfold-repeats es)))
43
44     (if (music? alts)
45         (ly-set-mus-property
46          music 'alternatives
47          (unfold-repeats alts)))
48
49     (if (music? body)
50         (ly-set-mus-property
51          music 'body
52          (unfold-repeats body)))
53
54     (if (music? e)
55         (ly-set-mus-property
56          music 'element
57          (unfold-repeats e)))
58
59
60     music))
61