[CM] Parsing MIDI files with CM

Orm Finnendahl finnendahl@folkwang-hochschule.de
Fri, 17 Mar 2006 08:49:53 +0100


Am 16. März 2006, 19:10 Uhr (-0500) schrieb Doug Geers:
> I'm sorry if this is another newbie question, but I'm looking for help
> parsing existing MIDI files into a format that is easier for CM to
> handle, such as lists of (pitch velocity), or, even better, (pitch
> velocity duration) for all notes per channel.

It used to be possible with map-subobjects, using the :type keyword,
but this function seems to have disappeared although still somewhat
documented in the dictionary.

Try this instead:

(let ((result nil)
      (file "/tmp/test.midi"))
      (map-objects 
       #'(lambda (x) 
	   (when (eq 'MIDI (object-name x))
	     (push (list (sv x time) 
	     	   	 (sv x keynum) 
	     		 (sv x amplitude) 
	     		 (sv x duration)) nums)))
       (import-events file))
       (nreverse result))

You can adopt to your needs if you want to filter channels, remap etc...

--
Orm