Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / scm / autochange.scm
blobc445997199b8f53e6ac968cdac97b0098a3e594c
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; autochange - fairly related to part combining.
6 (define-public (make-autochange-music parser music)
7   (define (generate-split-list change-moment event-list acc)
8     (if (null? event-list)
9         acc
10         (let* ((now-tun (caar event-list))
11                (evs (map car (cdar event-list)))
12                (now (car now-tun))
13                (notes (filter (lambda (x)
14                                 (equal? (ly:event-property  x 'class) 'note-event))
15                               evs))
16                (pitch (if (pair? notes)
17                           (ly:event-property (car notes) 'pitch)
18                           #f)))
19           ;; tail recursive.
20           (if (and pitch (not (= (ly:pitch-steps pitch) 0)))
21               (generate-split-list #f
22                                    (cdr event-list)
23                                    (cons (cons
25                                           (if change-moment
26                                               change-moment
27                                               now)
28                                           (sign (ly:pitch-steps pitch))) acc))
29               (generate-split-list
30                (if pitch #f now)
31                (cdr event-list) acc)))))
32   
33   (let* ((m (make-music 'AutoChangeMusic))
34         (m1 (make-non-relative-music (context-spec-music music 'Voice "one")))
35          (context-list (recording-group-emulate music
36                                                 (ly:parser-lookup parser 'partCombineListener)))
37          (evs (car context-list))
38          (rev (reverse! (cdar context-list)))
39          (split (reverse! (generate-split-list
40                            #f
41                            rev
42                            '())
43                           '())))
44     (set! (ly:music-property m 'element) music)
45     (set! (ly:music-property m 'split-list) split)
46     m))