[CM] subobject-->:time

web musicae webmusicae@hotmail.com
Fri, 29 Apr 2005 10:01:44 +0000


Helllo Rick, I'm surprised, was really easy with sv function. Tanks!. But, 
why 'sv' is not in  Common Music Dictionary?. Maybe is a old feautre of cm < 
2.6?. Do you advice me any complet documentation?.

&gt;From: Rick Taube &lt;taube@uiuc.edu&gt;
&gt;To: &quot;web musicae&quot; &lt;webmusicae@hotmail.com&gt;
&gt;CC: cmdist@ccrma.Stanford.EDU
&gt;Subject: Re: [CM] subobject--&gt;:time
&gt;Date: Thu, 28 Apr 2005 17:56:17 -0500
&gt;
&gt;&gt;Hello. How can I access to :time value of subobjects in a sequence.
&gt;&gt;I need obtain a list llike
&gt;&gt;((time note duration) ...)  ;from a midi-file
&gt;
&gt;(loop for x in (subobjects #&amp;myseq)
&gt;       collect (list (sv x time) (sv x keynum) (sv x duration)))
&gt;
&gt;&gt;And second question. I'd want to realize a converter from midi time
&gt;&gt;to score time, then need implement silence events (?) -then I need
&gt;&gt;resolve de first question. Example from (after import-events):
&gt;&gt;(midi :time 0 :keynum 60 :duration 1 ...)
&gt;&gt;(midi :time 3 :keynum 67 :duration 1...)
&gt;&gt;...
&gt;&gt;to
&gt;&gt;(c4 q)
&gt;&gt;(rest h)
&gt;&gt;(g4 q)
&gt;&gt;...
&gt;
&gt;(defun seq-to-notes (seq)
&gt;   (let ((endtime 0))
&gt;     (loop for x in (subobjects seq)
&gt;        for begtime = (sv x time)
&gt;        for duration = (sv x duration)
&gt;        if (&gt; begtime endtime) collect (list 'rest (- begtime
&gt;endtime))
&gt;        collect (list (note (sv x keynum)) duration)
&gt;        do (setq endtime (+ begtime duration)))))
&gt;
&gt;
&gt;;; test
&gt;(new seq :name 'foo
&gt;      :subobjects
&gt;      (loop repeat 20
&gt;         for beg = 0 then (+ beg (pick 1 2 3 4))
&gt;         collect (new midi :time beg :duration 1
&gt;                      :keynum (random 100))))
&gt;
&gt;(seq-to-notes #&amp;foo)
&gt;
&gt;((F6 1) (REST 3) (EF0 1) (REST 2) (FS0 1) (REST 3) (BF4 1) (REST 2)
&gt;(A2 1)
&gt;  (REST 3) (FS1 1) (G5 1) (REST 1) (F-1 1) (B4 1) (REST 3) (D4 1)
&gt;(D3 1) (BF3 1)
&gt;  (EF3 1) (REST 3) (EF4 1) (REST 2) (A4 1) (REST 3) (C0 1) (BF3 1)
&gt;(REST 2)
&gt;  (D0 1) (REST 1) (D-1 1) (REST 3) (F2 1))
&gt;?
&gt;
&gt;
&gt;
&gt;--rick
&gt;
&gt;_______________________________________________
&gt;Cmdist mailing list
&gt;Cmdist@ccrma.stanford.edu
&gt;http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist