comparison implementations/midi/midifile-import.lisp @ 212:619194befdd4

add identifier and timebase slots to midifile composition class Ignore-this: 4e72a0860344399452bea196c3739bbf darcs-hash:20090524150506-16a00-bce845ccf20a9289a4015fb58287f25ebfa178ad.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:17 +0000
parents 1f3873585a5d
children de60993404c1
comparison
equal deleted inserted replaced
211:e2839225f6fb 212:619194befdd4
11 "Creates an identifier for MIDI files, based on a pathname" 11 "Creates an identifier for MIDI files, based on a pathname"
12 (make-instance 'midifile-identifier :path pathname)) 12 (make-instance 'midifile-identifier :path pathname))
13 13
14 (defmethod get-composition ((identifier midifile-identifier)) 14 (defmethod get-composition ((identifier midifile-identifier))
15 (%initialise-midifile-composition (midi:read-midi-file 15 (%initialise-midifile-composition (midi:read-midi-file
16 (midifile-identifier-pathname identifier)))) 16 (midifile-identifier-pathname identifier))
17 identifier))
17 18
18 (defun %initialise-midifile-composition (midifile) 19 (defun %initialise-midifile-composition (midifile identifier)
19 ;; Takes a midifile object (from the "MIDI" package) 20 ;; Takes a midifile object (from the "MIDI" package)
20 ;; and returns an amuse midi object 21 ;; and returns an amuse midi object
21 ;; FIXME: gets it wrong if patch changes in mid-note 22 ;; FIXME: gets it wrong if patch changes in mid-note
22 ;; FIXME: assumes controllers are global in scope and location 23 ;; FIXME: assumes controllers are global in scope and location
23 (let ((tracks (midi:midifile-tracks midifile)) 24 (let ((tracks (midi:midifile-tracks midifile))
127 :time-signatures (if time-sigs 128 :time-signatures (if time-sigs
128 (sort time-sigs #'time<) 129 (sort time-sigs #'time<)
129 (list (make-standard-time-signature-period 130 (list (make-standard-time-signature-period
130 4 4 0 (/ last-time division)))) 131 4 4 0 (/ last-time division))))
131 :tempi (sort tempi #'time<) 132 :tempi (sort tempi #'time<)
132 :key-signatures (sort key-sigs #'time<)))) 133 :key-signatures (sort key-sigs #'time<)
134 :identifier identifier
135 :midi-timebase division)))
133 (sequence:adjust-sequence composition 136 (sequence:adjust-sequence composition
134 (length notes) 137 (length notes)
135 :initial-contents (sort notes #'time<))))) 138 :initial-contents (sort notes #'time<)))))
136 139
137 (defun make-event-from-on-off-pair (note-on cut-off divisions track patch) 140 (defun make-event-from-on-off-pair (note-on cut-off divisions track patch)