- (map copy-one-state (span-state vs)) )
-
- (define (analyse-notes now-state)
- (let*
- (
- (vs1 (car (voice-states now-state)))
- (vs2 (cdr (voice-states now-state)))
-
- (notes1 (note-events vs1))
- (durs1 (sort (map (lambda (x) (ly:music-property x 'duration)) notes1) ly:duration<?))
- (pitches1 (sort
- (map (lambda (x) (ly:music-property x 'pitch)) notes1) ly:pitch<?))
- (notes2 (note-events vs2))
- (durs2 (sort (map (lambda (x) (ly:music-property x 'duration)) notes2) ly:duration<?))
- (pitches2 (sort
- (map (lambda (x) (ly:music-property x 'pitch)) notes2) ly:pitch<?)) )
-
- (cond
- ((> (length notes1) 1) (put 'apart))
- ((> (length notes2) 1) (put 'apart))
- ((not (= (length notes1) (length notes2)))
- (put 'apart))
- ((and
- (= (length durs1) 1)
- (= (length durs2) 1)
- (not (equal? (car durs1) (car durs2))))
-
- (put 'apart))
- (else
- (if (and (= (length pitches1) (length pitches2)))
- (if (and (pair? pitches1)
- (pair? pitches2)
- (< chord-threshold (ly:pitch-steps
- (ly:pitch-diff (car pitches1) (car pitches2)))))
- (put 'apart)
-
- ;; copy previous split state from spanner state
- (begin
- (if (previous-voice-state vs1)
- (copy-state-from voice-state-vec1
- (previous-voice-state vs1)))
- (if (previous-voice-state vs2)
- (copy-state-from voice-state-vec2
- (previous-voice-state vs2)))
- (if (and (null? (span-state vs1)) (null? (span-state vs2)))
- (put 'chords))
-
- ))))
- )))
-
-
-
- (if (< ri (vector-length result))
- (let*
- ((now-state (vector-ref result ri))
- (vs1 (car (voice-states now-state)))
- (vs2 (cdr (voice-states now-state))))
-
- (cond
- ((not vs1) (put 'apart))
- ((not vs2) (put 'apart))
- (else
- (let*
- (
- (active1 (previous-span-state vs1))
- (active2 (previous-span-state vs2))
-
- (new-active1 (span-state vs1))
- (new-active2 (span-state vs2)) )
- (if
- pc-debug
- (display (list (when now-state) ri
- active1 "->" new-active1
- active2 "->" new-active2
- "\n")))
-
-
-
- (if (and (synced? now-state)
- (equal? active1 active2)
- (equal? new-active1 new-active2))
-
- (analyse-notes now-state)
-
- ;; active states different:
- (put 'apart)
- ))
-
- ; go to the next one, if it exists.
- (analyse-time-step (1+ ri))
- )))))
+ (if (< result-idx (vector-length result))
+ (let* ((now-state (vector-ref result result-idx))
+ (vs1 (car (voice-states now-state)))
+ (vs2 (cdr (voice-states now-state))))
+
+ (cond ((not vs1) (put 'apart))
+ ((not vs2) (put 'apart))
+ (else
+ (let ((active1 (previous-span-state vs1))
+ (active2 (previous-span-state vs2))
+ (new-active1 (span-state vs1))
+ (new-active2 (span-state vs2)))
+ (if #f ; debug
+ (display (list (when now-state) result-idx
+ active1 "->" new-active1
+ active2 "->" new-active2
+ "\n")))
+ (if (and (synced? now-state)
+ (equal? active1 active2)
+ (equal? new-active1 new-active2))
+ (analyse-notes now-state)
+
+ ;; active states different:
+ (put 'apart)))
+
+ ;; go to the next one, if it exists.
+ (analyse-time-step (1+ result-idx)))))))