+ (voice-state-vec1 (make-voice-states evl1))
+ (voice-state-vec2 (make-voice-states evl2))
+ (result (make-split-state voice-state-vec1 voice-state-vec2))
+ (chord-min-diff (car chord-range))
+ (chord-max-diff (cdr chord-range)))
+
+ ;; Go through all moments recursively and check if the events of that
+ ;; moment contain a part-combine-force-event override. If so, store its
+ ;; value in the forced-configuration field, which will override. The
+ ;; previous configuration is used to determine non-terminated settings.
+ (define (analyse-forced-combine result-idx prev-res)
+
+ (define (get-forced-event x)
+ (and (ly:in-event-class? x 'part-combine-force-event)
+ (cons (ly:event-property x 'forced-type)
+ (ly:event-property x 'once))))
+ (define (part-combine-events vs)
+ (if (not vs)
+ '()
+ (filter-map get-forced-event (events vs))))
+ ;; end part-combine-events
+
+ ;; forced-result: Take the previous config and analyse whether
+ ;; any change happened.... Return new once and permanent config
+ (define (forced-result evt state)
+ ;; sanity check, evt should always be (new-state . once)
+ (if (not (and (pair? evt) (pair? state)))
+ state
+ (if (cdr evt)
+ ;; Once-event, leave permanent state unchanged
+ (cons (car evt) (cdr state))
+ ;; permanent change, leave once state unchanged
+ (cons (car state) (car evt)))))
+ ;; end forced-combine-result
+
+ ;; body of analyse-forced-combine:
+ (if (< result-idx (vector-length result))
+ (let* ((now-state (vector-ref result result-idx)) ; current result
+ ;; Extract all part-combine force events
+ (evts (if (synced? now-state)
+ (append
+ (part-combine-events (car (voice-states now-state)))
+ (part-combine-events (cdr (voice-states now-state))))
+ '()))
+ ;; result is (once-state permament-state):
+ (state (fold forced-result (cons 'automatic prev-res) evts))
+ ;; Now let once override permanent changes:
+ (force-state (if (equal? (car state) 'automatic)
+ (cdr state)
+ (car state))))
+ (set! (forced-configuration (vector-ref result result-idx))
+ force-state)
+ ;; For the next moment, ignore the once override (car stat)
+ ;; and pass on the permanent override, stored as (cdr state)
+ (analyse-forced-combine (1+ result-idx) (cdr state)))))
+ ;; end analyse-forced-combine
+
+