# HG changeset patch # User Jamie Forth # Date 1298546598 0 # Node ID bba5e8571b92faf45b2d9720707e47c89f316e38 # Parent e5ff7d53f08456f094df73ebf14b22afacbb64e9 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. diff -r e5ff7d53f084 -r bba5e8571b92 implementations/midi/classes.lisp --- 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 diff -r e5ff7d53f084 -r bba5e8571b92 implementations/midi/constructors.lisp --- 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)) diff -r e5ff7d53f084 -r bba5e8571b92 implementations/midi/methods.lisp --- 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)) diff -r e5ff7d53f084 -r bba5e8571b92 implementations/midi/midifile-import.lisp --- 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