Home  Previous: controllers  Next: meta-text  Contents  
transformer

Transformer

A TRANSFORMER is a part which modifies selected events from another part. There are three steps to setting up a transformer.

  1. Select a part to process. The source part is not modified and may be muted.
  2. Designate a function to select MIDI events to process. The default is to process all events.
  3. Designate a function to transform selected events. The default is to return selected events unchanged.
(MAKE-TRANSFORMER name source &key ...)
(TRANSFORMER name source &keys ...)
    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)
  

Example 1

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)))))))
  

Home  Previous: controllers  Next: meta-text  Top  Contents