-(define noticed '())
-(define part-combine-listener '())
-
-; UGH - should pass noticed setter to part-combine-listener
-(define-public (set-part-combine-listener x)
- (set! part-combine-listener x))
-
-(define-public (notice-the-events-for-pc context lst)
- "add CONTEXT-ID, EVENT list to NOTICED variable."
-
- (set! noticed (acons (ly:context-id context) lst noticed)))
-
-(define-public (make-part-combine-music music-list)
- (let ((m (make-music 'PartCombineMusic))
- (m1 (make-non-relative-music (context-spec-music (car music-list) 'Voice "one")))
- (m2 (make-non-relative-music (context-spec-music (cadr music-list) 'Voice "two"))))
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(define-public (recording-group-emulate music odef)
+ "Interprets music according to odef, but stores all events in a chronological list, similar to the Recording_group_engraver in 2.8 and earlier"
+ (let*
+ ((context-list '())
+ (now-mom (ly:make-moment 0 0))
+ (global (ly:make-global-context odef))
+ (mom-listener (ly:make-listener
+ (lambda (tev)
+ (set! now-mom (ly:event-property tev 'moment)))))
+ (new-context-listener
+ (ly:make-listener
+ (lambda (sev)
+ (let*
+ ((child (ly:event-property sev 'context))
+ (this-moment-list
+ (cons (ly:context-id child) '()))
+ (dummy
+ (set! context-list (cons this-moment-list context-list)))
+ (acc '())
+ (accumulate-event-listener
+ (ly:make-listener (lambda (ev)
+ (set! acc (cons (cons ev #t) acc)))))
+ (save-acc-listener (ly:make-listener (lambda (tev)
+ (if (pair? acc)
+ (let ((this-moment (cons (cons now-mom (ly:context-property child 'instrumentTransposition))
+ acc)))
+ (set-cdr! this-moment-list (cons this-moment (cdr this-moment-list)))
+ (set! acc '())))))))
+ (ly:add-listener accumulate-event-listener (ly:context-event-source child) 'music-event)
+ (ly:add-listener save-acc-listener (ly:context-event-source global) 'OneTimeStep))))))
+ (ly:add-listener new-context-listener (ly:context-events-below global) 'AnnounceNewContext)
+ (ly:add-listener mom-listener (ly:context-event-source global) 'Prepare)
+ (ly:interpret-music-expression (make-non-relative-music music) global)
+ context-list))
+
+(define-public (make-part-combine-music parser music-list)
+ (let* ((m (make-music 'PartCombineMusic))
+ (m1 (make-non-relative-music (context-spec-music (first music-list) 'Voice "one")))
+ (m2 (make-non-relative-music (context-spec-music (second music-list) 'Voice "two")))
+ (listener (ly:parser-lookup parser 'partCombineListener))
+ (evs2 (recording-group-emulate m2 listener))
+ (evs1 (recording-group-emulate m1 listener)))
+