[CM] midifile import

Ralf Mattes rm at seid-online.de
Thu Mar 19 07:23:59 PDT 2009


On Thu, 2009-03-19 at 14:39 +0100, Orm Finnendahl wrote:
> Rick,

Hi everyone,

> 
> Am Donnerstag, den 19. März 2009 um 08:06:15 Uhr (-0500) schrieb Rick Taube:
> > orm i would not want to add anything that actually imports non-standard 
> > messages.
> 
> I certainly agree (and wouldn't do it either).

> > however perhaps adding control over whether cm actually signals an error 
> > or just a warning for illegal messages would be useful?
> > so to import a midifile with bogus messages dropped you would do   
> > (midi-file-import ...   :strict nil)
> 
> Sounds like an excellent idea to me!

Sorry, but why not use the wonderful features of Common Lisp? Recovering
from parsing errors/problems seems like the perfect job for conditions
and restarts. Just define a condition like:
 
 (define-condition midifile-error (error)
   ((message :initarg :message 
             :accessor message-of 
             :documentation "Some meaningful error message")
    (tick-time :initarg :tick-time
             :accessor tick-time-of
             :documentation "When in the stream did the parsing error
happen)
    (part    :initarg :part 
             :accessor part-of
             :documentation "Waht part is messed up")))

(defun midifile-error (message &key tick-time part)
   (error midifile-error :message message :part part :tick-time
tick-ime))

and then later on use 

 (midifile-error "Parse time signature: expected 4 byte but only got
2" :ticks ticks)


and add some useful restarts to the parsing code (like ignore-message,
use-data, abort ...).

 Cheers, RalfD
   

> --
> Orm
> 
> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist




More information about the Cmdist mailing list