]> git.donarmstrong.com Git - lilypond.git/blob - input/test/voicify-chords.ly
f472e04f7c290af0dca820f3bc8482f314778318
[lilypond.git] / input / test / voicify-chords.ly
1   
2 #(define (voicify-list lst number)
3    "Make a list of Musics.
4
5    voicify-list :: [ [Music ] ] -> number -> [Music]
6    LST is a list music-lists.
7 "
8
9    (if (null? lst) '()
10        (cons (context-spec-music
11               (make-sequential-music
12                (list
13                 (make-voice-props-set number)
14                 (make-simultaneous-music (car lst))))
15
16               "Voice"  (number->string number))
17               (voicify-list (cdr lst) (+ number 1))
18        ))
19    )
20
21 #(define (voicify-chord ch)
22   "Split the parts of a chord into different Voices using separator"
23    (let* ((es (ly-get-mus-property ch 'elements)))
24
25
26      (ly-set-mus-property! ch 'elements
27        (voicify-list (split-list es music-separator?) 0))
28      ch
29    ))
30
31 #(define (voicify-music m)
32    "Recursively split chords that are separated with \\ "
33    
34    (if (not (music? m))
35        (begin (display m)
36        (error "not music!"))
37        )
38    (let*
39        ((es (ly-get-mus-property m 'elements))
40         (e (ly-get-mus-property m 'element))
41         )
42         
43      (if
44       (and (equal? (ly-music-name m) "Simultaneous_music")
45            (reduce (lambda (x y ) (or x y))     (map music-separator? es)))
46       (voicify-chord m)
47       (begin
48         (if (pair? es)
49             (ly-set-mus-property! m 'elements (map voicify-music es)))
50         (if (music? e)
51             (ly-set-mus-property! m 'element  (voicify-music e)))
52             
53         m)
54       
55       )
56      ))
57
58 \score { \notes \context Staff \relative c'' 
59 \apply #voicify-music {
60    c4   <g' \\ c, \\ f \\ d > f g < c \\ d> a 
61 }
62 }
63
64