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