[CM] CM output to CMN

Anders Vinjar cmdist@ccrma.Stanford.EDU
20 Aug 2003 09:31:36 +0200


    MP> 	1. creating the appropriate midimsg objects and adding them to the
    MP> 	   list of events --> but thereis no 'object->cmn' method for
    MP> 	   midimsg objects; I could write one I suppose but ... 

Theres so many things youd typically want to do with your
cmn-output after adding musical data that an effective way is to
output to a .cmn-file after massaging cm-data, and add
cmn-entitites and adjustings subsequently.

But if all you want is some simple input of meters or some such
you can use midimsg like here:

(defmethod object->cmn ((obj midimsg))
  ;; using 'data as staff-id passing 'msg to cmn:
  (list (midimsg-data obj) (midimsg-msg obj)))

giving access to things like:

=>  output (new midimsg :time (now) :data stf :msg '(meter 3 4))

or make your own object:

(defobject cmn-data () 
  ((staff :initform 0) 
   (time :initform 0)
   (data :initform '()))
  (:parameters staff time data))

(defmethod object->cmn ((obj cmn-data))
  (list (cmn-data-staff obj) (cmn-data-data obj)))

=>  output (new cmn-data :staff stf :time (now) :data '(meter 2 4))

ie:

(define (testit stf len nts)
  (let ((nts (new heap :notes nts))
        ;; choose quater or two eighths
        (rhy (new random
               :of (list 1 
                         (new cycle :of '(1/2 1/2))))))
    (process while (< (now) len)
             for n = (next nts)
	     for i from 0 by 2
             for r = (next rhy)
             output (new midi :time (now)
                         :duration r
                         :keynum n
                         :channel stf)
             when (= i 4) output (new cmn-data :staff stf :time (now) :data '(meter 2 4))
	     ;;when (= i 12) output (new midimsg :time (now) :data stf :msg '(meter 3 4))
             wait r)))

from intro.cm:

(events (list (testit 0 12 '(c3 d ef f g))
              (testit 1 12 '(c5 d ef f g)))
        "testit.eps" 
        :staffing staffs
        :size 24
        :title "Hiho!"
	:automatic-rests nil)