[Class]
cmn

Holds note and staff expressions (variables and function calls) to manuscript with CMN streams.

cmn supports the following slot initializations:

:time number
The start time of the object in the score.
:staff number
The identifier of the staff to which the expression is added. Defaults to 0.
:expr expr
The CMN expession to add to the staff. If the value is a note name or keynum and a :duration for the object is specfied then a new CMN note definition is added to the staff at the current score time. Otherwise, the value of :expr can be any CMN expression (function call list or variable name) to add to the staff. For sake of clarity the :expr initialzation can also be specified as :note.
:duration number
The duration (in seconds) of a :note definition.
:data list
A list of additional expressions to add to the note or staff.

Examples:

Example 1. CMN expressions.

;;; a meter expression
(new cmn :time 0 :expr '(meter 3 4))

;;; a note defintion
(new cmn :time 0 :note 'c4 :duration 3)

;;; a note in staff 3 with markup added
(new cmn :staff 3 :expr 'c4 :duration .5
     :data '(accent ff))

Example 2. Outputting CMN objects to scores.

(new seq :name 'sevens
     :subobjects
     (list (new cmn :time 0 :expr '(meter 7 8))
           (new cmn :time 0 :expr 'cs-major)
           (new cmn :time 0 :note 'c4
                :duration (rhythm 'h..)
                :data '(pppp))
           (new cmn :time 3.5
                :note 'df5 :duration (rhythm 'e)
                :data '(accent sfz))
           (new cmn :time 4 :note 'f4
                :duration 2
                :data '(mp fermata))))

;;; generate an .eps file
(events #&sevens "sevens.eps")

;;; generate a .cmn input file
(events #&sevens "sevens.cmn" :size 20)

;;; generate a .mid file
(events #&sevens "sevens.mid")
Example 3. CMN output to MIDI files includes tempo, key and meter markups.

(midi-file-print "sevens.mid")
File: sevens.mid 
Format: 0
Tracks: 1
Division: 480
Track 0, length 52
       0 #<Tempo Change 1000 ms>
       0 #<Time Signature 7/8 (24 clocks, 8 32nds)>
       0 #<Key Signature 7 sharps, major>
       0 #<Note-On 0 60 64>
    1680 #<Note-Off 0 60 127>
       0 #<Note-On 0 73 64>
     240 #<Note-Off 0 73 127>
       0 #<Note-On 0 65 64>
     960 #<Note-Off 0 65 127>
"seven.mid"

Example 3. Generate random metered measures in customized staffs.

(define (ranmeas meas maxstaff low hi)
  (process with cnt = 0 and bea
           and mea = (new heap :of '( 7 3 5 4))
           and num = 1
           ;; start new measure...
           if (= cnt 0)
           set bea = (next mea)
           and set cnt = bea
           and set num = (+ num 1)
           and output (new cmn :time (now)
                           :expr `(meter ,bea 8))
           ;; always output note, 50% are accented
           output (new cmn :time (now)
                       :note (between low hi)
                       :staff (random maxstaff)
                       :duration 1/2
                       :data (odds .5 '(accent)))
           set cnt = (- cnt 1)
           until (and (= cnt 0) (= num meas))
           wait 1/2))

;; output a single staff
(events (ranmeas 15 1 60 80) "test.eps" :size 20)

;;; define custom staff descriptions for the cmn score.
(define ins
  '((0 :name "Bb Cl." :clef :treble)
    (1 :name "Viola" :clef :alto)))

;;; insure staffing, title and font size for score.
(io "duet.eps" :staffing ins :size 20
    :title "Etude for Two")

(events (ranmeas 15 2 50 80) "duet.eps")

See also: