Mercurial > hg > amuse
changeset 281:4a03a1478c02
add identifier and timebase slots to midifile composition class
Ignore-this: 4e72a0860344399452bea196c3739bbf
darcs-hash:20090524150506-16a00-bce845ccf20a9289a4015fb58287f25ebfa178ad.gz
author | j.forth <j.forth@gold.ac.uk> |
---|---|
date | Sun, 24 May 2009 16:05:06 +0100 |
parents | 9ce6b954d403 |
children | 1499e5d1b8a7 |
files | implementations/geerdes/classes.lisp implementations/geerdes/constructors.lisp implementations/geerdes/methods.lisp implementations/midi/classes.lisp implementations/midi/methods.lisp implementations/midi/midifile-import.lisp implementations/midi/package.lisp |
diffstat | 7 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/implementations/geerdes/classes.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/geerdes/classes.lisp Sun May 24 16:05:06 2009 +0100 @@ -29,10 +29,6 @@ :accessor %midi-constituents) (midi-events :initarg :midi-events :accessor %midi-events) - (midi-timebase :initarg :midi-timebase - :accessor %midi-timebase) - (identifier :initarg :id - :accessor %fast-identifier) (db-cat-id :initarg :cat-id :accessor %db-cat-id) (db-file-id :initarg :file-id
--- a/implementations/geerdes/constructors.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/geerdes/constructors.lisp Sun May 24 16:05:06 2009 +0100 @@ -4,7 +4,7 @@ (defmethod %initialise-notes ((composition geerdes-composition)) (let ((notes) (l 0) (last-time 0) (monody-notes) (monody (make-instance 'geerdes-monody :file-id (file-id composition))) - (timebase (%midi-timebase composition))) + (timebase (midi-timebase composition))) (dolist (row (%midi-events composition)) (let* ((note (if (pitched-row-p row) (make-geerdes-pitched-event (%fast-pitch row) @@ -47,7 +47,7 @@ ;; FIXME: Should the duration of composition be affected by this? On ;; the one hand, it makes no difference to the musical content, but ;; on the other, it seems illogical to reach outside the period. - (let ((timebase (%midi-timebase composition)) + (let ((timebase (midi-timebase composition)) (time-sigs) (tempi) (mystery 0))
--- a/implementations/geerdes/methods.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/geerdes/methods.lisp Sun May 24 16:05:06 2009 +0100 @@ -62,7 +62,7 @@ (timebase (second file-info)) (file-id (first file-info)) (composition (make-instance 'geerdes-composition - :id identifier + :identifier identifier :file-id file-id :cat-id cat-id :midi-timebase timebase))) @@ -83,7 +83,7 @@ (timebase (second file-info)) (cat-id (first file-info)) (composition (make-instance 'geerdes-composition - :id identifier + :identifier identifier :cat-id cat-id :file-id file-id :midi-timebase timebase)))
--- a/implementations/midi/classes.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/midi/classes.lisp Sun May 24 16:05:06 2009 +0100 @@ -14,8 +14,12 @@ :initform 'nil :accessor %midi-key-signatures) (misc-controllers :initarg :controllers - :initform 'nil - :accessor %midi-misc-controllers)) + :initform 'nil + :accessor %midi-misc-controllers) + (identifier :initarg :identifier + :reader identifier) + (midi-timebase :initarg :midi-timebase + :reader %midi-timebase)) (:documentation "Class for midi compositions, with time signatures, tempi, key signatures and other controllers as lists in slots"))
--- a/implementations/midi/methods.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/midi/methods.lisp Sun May 24 16:05:06 2009 +0100 @@ -55,6 +55,10 @@ (defmethod (setf key-signatures) (sequence (composition midi-composition)) (setf (%midi-key-signatures composition) sequence)) +(defgeneric midi-timebase (composition)) +(defmethod midi-timebase ((composition midi-composition)) + (%midi-timebase composition)) + ;; FIXME: This ought to call-next-method and operate on the result, ;; rather than calling internals from the other package (defmethod copy-event ((event midi-pitched-event))
--- a/implementations/midi/midifile-import.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/midi/midifile-import.lisp Sun May 24 16:05:06 2009 +0100 @@ -13,9 +13,10 @@ (defmethod get-composition ((identifier midifile-identifier)) (%initialise-midifile-composition (midi:read-midi-file - (midifile-identifier-pathname identifier)))) + (midifile-identifier-pathname identifier)) + identifier)) -(defun %initialise-midifile-composition (midifile) +(defun %initialise-midifile-composition (midifile identifier) ;; Takes a midifile object (from the "MIDI" package) ;; and returns an amuse midi object ;; FIXME: gets it wrong if patch changes in mid-note @@ -129,7 +130,9 @@ (list (make-standard-time-signature-period 4 4 0 (/ last-time division)))) :tempi (sort tempi #'time<) - :key-signatures (sort key-sigs #'time<)))) + :key-signatures (sort key-sigs #'time<) + :identifier identifier + :midi-timebase division))) (sequence:adjust-sequence composition (length notes) :initial-contents (sort notes #'time<)))))
--- a/implementations/midi/package.lisp Fri May 22 22:12:15 2009 +0100 +++ b/implementations/midi/package.lisp Sun May 24 16:05:06 2009 +0100 @@ -2,6 +2,7 @@ (:use #:common-lisp #:amuse #:amuse-utils #:amuse-tools) (:export #:midi-composition #:midifile-id + #:midifile-identifier-pathname #:midi-pitched-event #:midi-percussive-event #:make-midi-pitched-event @@ -14,4 +15,5 @@ #:midi-drum-sound #:microsecond-per-crotchet-to-bpm #:midi-patch + #:midi-timebase ))