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