]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/music-map.ly
Split WWW target in two stages WWW-1 and WWW-2
[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
6 single piece of music to an entire music expression. In this example,
7 the the function @code{notes-to-skip} changes a note to a skip. When
8 applied to an entire music expression in the 1st measure, the scripts
9 and dynamics are left over. These are put onto the 2nd measure."
10
11 }
12
13 \version "2.10.0"
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:music-property m 'types))
20    (let* ((newmus (make-music 'SkipEvent)))
21     (map
22      (lambda (x) (ly:music-set-property! newmus (car x) (cdr x)))
23      (ly:music-mutable-properties m))
24     newmus
25   )
26    m)
27 )
28
29
30 \layout { ragged-right= ##t }
31
32 foobar =  \transpose c c' { c4\>-^ c4-^ c4\!-^ c4-^  } 
33
34
35 \relative c''  \context Voice {
36   \foobar
37
38   << \applyMusic #(lambda (x) (music-map notes-to-skip x))
39      \foobar
40      { d8 d d d d d d d  } >> 
41 }