changeset 249:bba5e8571b92

Hack in linked-events for the midi package. Some refactoring of the constructors for this and geerdes might be helpful, since neither lend themselves to using initialize-instance for performing the linking.
author Jamie Forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents e5ff7d53f084
children b3260d1d2419
files implementations/midi/classes.lisp implementations/midi/constructors.lisp implementations/midi/methods.lisp implementations/midi/midifile-import.lisp
diffstat 4 files changed, 22 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/implementations/midi/classes.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/implementations/midi/classes.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -38,14 +38,16 @@
   ((channel :accessor %midi-message-channel :initarg :channel)
    (track :accessor %midi-message-track :initarg :track)))
 
-(defclass midi-pitched-event (standard-chromatic-pitched-event midi-message)
+(defclass midi-pitched-event (standard-chromatic-pitched-event
+			      linked-event midi-message)
   ((velocity :initarg :velocity
 	     :accessor %midi-pitched-event-velocity)
    (patch :initarg :patch
 	  :accessor %midi-pitched-event-patch))
   (:documentation "Adds MIDI information to chromatic-pitched-event"))
 
-(defclass midi-percussive-event (standard-percussive-event midi-message)
+(defclass midi-percussive-event (standard-percussive-event
+				 linked-event midi-message)
   ((velocity :initarg :velocity
 	     :accessor %midi-percussive-event-velocity)
    (patch :initarg :patch
--- a/implementations/midi/constructors.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/implementations/midi/constructors.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -3,8 +3,9 @@
 (defun make-midifile-identifier (pathname)
   (make-instance 'midifile-identifier :path pathname))
 
-(defun make-midi-pitched-event (pitch-number velocity patch
-				channel track onset duration)
+(defun make-midi-pitched-event (pitch-number velocity patch channel
+				track onset duration &optional
+				composition)
   (make-instance 'midi-pitched-event
 		 :number pitch-number
 		 :velocity velocity
@@ -12,10 +13,12 @@
 		 :channel channel
 		 :track track
 		 :time onset
-		 :interval duration))
+		 :interval duration
+		 :composition composition))
 
-(defun make-midi-percussive-event (sound velocity patch
-				   channel track onset duration)
+(defun make-midi-percussive-event (sound velocity patch channel track
+				   onset duration &optional
+				   composition)
   (make-instance 'midi-percussive-event
 		 :sound sound
 		 :velocity velocity
@@ -23,6 +26,7 @@
 		 :channel channel
 		 :track track
 		 :time onset
-		 :interval duration))
+		 :interval duration
+		 :composition composition))
 
 
--- a/implementations/midi/methods.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/implementations/midi/methods.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -94,16 +94,16 @@
 (defmethod copy-event ((event midi-pitched-event))
   (with-slots (channel track (number amuse::number)
 		       (time amuse::time) (interval amuse::interval)
-		       velocity patch) event
+		       velocity patch composition) event
     (make-midi-pitched-event number velocity patch channel track time
-			     interval)))
+			     interval composition)))
 
 (defmethod copy-event ((event midi-percussive-event)) 
   (with-slots (channel track (time amuse::time)
 		       (interval amuse::interval) velocity patch
-		       sound) event
+		       sound composition) event
     (make-midi-percussive-event sound velocity patch channel track
-				time interval)))
+				time interval composition)))
 
 (defgeneric copy-time-signature (time-signature))
 (defmethod copy-time-signature ((time-signature standard-time-signature))
--- a/implementations/midi/midifile-import.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/implementations/midi/midifile-import.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -128,7 +128,10 @@
 				      :midi-timebase division)))
       (sequence:adjust-sequence composition
 				(length notes)
-				:initial-contents (sort notes #'time<)))))
+				:initial-contents (sort notes #'time<))
+      (sequence:dosequence (e composition t)
+	(%set-composition composition e))
+      composition)))
 
 (defun make-event-from-on-off-pair (note-on cut-off divisions track patch)
   (cond