A TRANSFORMER is a part which modifies selected events from another part. There are three steps to setting up a transformer.
MAKE-TRANSFORMER and TRANSFORMER are identical except TRANSFORMER binds the new part to the symbol name while MAKE-TRANSFORMER does not. The name argument should be quoted for MAKE-TRANSFORMER and unquoted for TRANSFORMER. name - Name for transformer part. source - The part to be modified. :filter - Function to select MIDI events to be modified, see below. The default is to select all events. :transform - Function to modify selected events, see below. The default returns selected events unchanged. :render-once - Boolean, if true do not repeat events within section, default nil. :remarks - Optional remarks text.
The filter function has the form (lambda part event) → bool Where part is the TRANSFORMER instance and event is a cons (time . midi-message) Where time is the relative event time in seconds. The part argument may be used to further process the time value. midi-message is the original message. The filter function should return true for selected events.
The transform function has form (lambda part event) → event-list Where part and event are the same as the filter function. The transform function should return (a possibly empty) list of MIDI events. The default is to return the argument event unchanged (lambda part event) → (list event)
Duplicate events on another channel.
;; Create source part ;; (qball piano-part piano :cue '((1 1 1)(1 2 1)) :key '(c4 c5)) ;; Create transform ;; (let ((input-channel (channel piano)) (output-channel 7)) (transformer new-piano piano-part :filter #'(lambda (part event) (declare (ignore part)) (let ((message (cdr event))) (and (midi-channel-message-p message) (= (channel message) input-channel)))) :transform #'(lambda (part event) (declare (ignore part)) (let ((time (car event)) (message (cdr event))) (list (cons time (duplicate-channel-message message :channel output-channel)))))))