]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/music-map.ly
b92b85386b740667d273882b05c8ebd2f0cd7127
[lilypond.git] / input / regression / music-map.ly
1 \header {
2
3 texidoc =
4
5 "With @code{music-map}, you can apply functions operating on a single
6 piece of music to an entire music expression. In this example, the
7 scripts and dynamics of the first measure of music are applied to the
8 2nd measure. "
9
10 }
11
12
13 \version "1.7.8"
14
15 #(define (notes-to-skip m)
16 "Convert all stuff with duration (notes, lyrics, bass figures, etc.) to skips.
17 Scripts and dynamics are maintained.
18 "
19   (if (memq 'rhythmic-event (ly:get-mus-property m 'types))
20         (let* ((newmus    (make-music-by-name 'SkipEvent)))
21                 (map
22                   (lambda (x) (ly:set-mus-property! newmus (car x) (cdr x)))
23                   (ly:get-mutable-properties m))
24                 newmus
25         )
26         m)
27 )
28
29
30 foobar = \notes \transpose c c' { c4-\>-^ c4-^ c4-\!-^ c4-^  } 
31
32 \score {
33   \notes \relative c''  \context Voice {
34         \foobar
35
36         < \apply #(lambda (x) (music-map x notes-to-skip))
37                 \foobar
38            { d2 d2 } > 
39 }}