all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* need help debugging edebug (Common lisp problem?)
@ 2010-12-14  6:00 rusi
  2010-12-14 14:59 ` Pascal J. Bourguignon
       [not found] ` <87vd2w43zf.fsf@fh-trier.de>
  0 siblings, 2 replies; 4+ messages in thread
From: rusi @ 2010-12-14  6:00 UTC (permalink / raw)
  To: help-gnu-emacs

The following function (from http://delysid.org/emacs/midi.el )
crashes edebug.
It gives

edebug-syntax-error: Invalid read syntax: "Failed matching",
([&optional ["named" symbolp]] [&rest &or ["repeat" form] loop-for-as
loop-with loop-initial-final] [&rest loop-clause])

Note: It loads correctly (or rather silently) if edebug is turned off

I have a feeling its in the loop (cl) macro. Can someone who knows CL
better have a look?

(defun smf-read-mtrk (length)
  "Read one MTrk chunk.
NoteOn/NoteOff and NoteOn/NoteOn(vel=0) event
pairs are unified into a Note event with a certain duration."
  (let ((end (+ (point) length))
	(notes (make-vector 16 nil))
	(ticks 0) (running-status 0))
    (dotimes (i 16) (aset notes i (make-vector 128 nil)))
    (loop while (< (point) end)
	  do (incf ticks (smf-read-varlen))
	  for event =
	  (let ((status (following-char)))
	    (if (/= (logand status #B10000000 ) #B10000000 )
		(if (= running-status 0)
		    (error "Seen data byte without running status")
		  (setq status running-status))
	      (forward-char 1))
	    (unless (= status #XFF ) (setq running-status status))
	    (let ((lower (logand status #X0F )))
	      (case (ash status -4)
		(8  (let* ((note (smf-read-byte)) (vel (smf-read-byte))
			   (old-note (aref (aref notes lower) note)))
		      (if (not old-note)
			  (list 'NoteOff lower note vel)
			(setcar (cdr old-note) 'Note)
			(setcdr (nthcdr 4 old-note)
				(list (- ticks (car old-note)) vel))
			(aset (aref notes lower) note nil))))
		(9  (let* ((note (smf-read-byte)) (vel (smf-read-byte))
			   (data (cons ticks (list 'NoteOn lower note vel))))
		      (if (= vel 0)
			  (let ((old-note (aref (aref notes lower) note)))
			    (if (not old-note)
				(cdr data)
			      (setcar (cdr old-note) 'Note)
			      (setcdr (nthcdr 4 old-note)
				      (list (- ticks (car old-note))))
			      (aset (aref notes lower) note nil)))
			(cdr (aset (aref notes lower) note data)))))
		(10 (list 'At lower (smf-read-byte) (smf-read-byte)))
		(11 (list 'CC lower (smf-read-byte) (smf-read-byte)))
		(12 (list 'PC lower (smf-read-byte)))
		(13 (list 'CP lower (smf-read-byte)))
		(14 (list 'PW lower (logior (smf-read-byte)
					    (lsh (smf-read-byte) 7))))
		(15 (case lower
		      (0  (append (list 'SysEx)
				  (loop repeat (smf-read-varlen) collect
					(smf-read-byte))))
		      (2  (let ((value (logior (smf-read-byte)
					       (lsh (smf-read-byte) 7))))
			    (list 'SongPosition value)))
		      (3  (list 'SongSelect (smf-read-byte)))
		      (6  (list 'TuneRequest))
		      (8  (list 'Clock))
		      (9  (list 'Tick))
		      (10 (list 'Start))
		      (11 (list 'Continue))
		      (12 (list 'Stop))
		      (14 (list 'ActiveSense))
		      (15 (smf-read-meta-event))
		      (t (error "Unknown stuff")))))))
	  until (eq event t) when event collect (cons ticks event))))


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-15  3:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14  6:00 need help debugging edebug (Common lisp problem?) rusi
2010-12-14 14:59 ` Pascal J. Bourguignon
2010-12-14 20:47   ` bolega
     [not found] ` <87vd2w43zf.fsf@fh-trier.de>
2010-12-15  3:50   ` Rustom Mody

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.