[gsharp-devel] MIDI conversion

Christophe Rhodes csr21 at cam.ac.uk
Wed Mar 10 23:26:12 UTC 2004


Hi,

On the off-chance that someone else will either find this useful, or
will comment on it: I had need of conversion routines between MIDI
format 0 and format 1 formats today.  Attached is a patch to midi.lisp
(which works standalone) to implement these conversions, via the
function (SETF MIDIFILE-FORMAT).  I have yet to encounter a format 2
file in the wild, so I haven't implemented anything related to that.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: midi.diff
URL: <https://mailman.common-lisp.net/pipermail/gsharp-devel/attachments/20040310/dc37a85d/attachment.ksh>
-------------- next part --------------

I eventually settled on (SETF MIDIFILE-FORMAT) as the interface as the
least bad of three options.  They were:
  * COERCE-TO-FORMAT midifile format
    (not clear whether this would preserve the identity of MIDIFILE)
  * CHANGE-CLASS midifile class
    (exposing FORMAT{0,1,2}-MIDIFILE to the world feels ugly)
  * (SETF MIDIFILE-FORMAT)
    (possibly surprising amount of work for a SETF function; possibly
    disguises the fact that the conversion is lossy)

In any case, the basic logic is there to support any of these three
interfaces, and probably the perfect solution that I haven't thought
of.

Also in this patch is a bugfix allowing midifiles in flat keys to be
written.

Cheers,

Christophe
-- 
http://www-jcsu.jesus.cam.ac.uk/~csr21/       +44 1223 510 299/+44 7729 383 757
(set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b)))
(defvar b "~&Just another Lisp hacker~%")    (pprint #36rJesusCollegeCambridge)


More information about the gsharp-devel mailing list