annotate implementations/midi-db/classes.lisp @ 330:2fbff655ba47 tip

Removed cpitch-adj and cents SQL columns
author Jeremy Gow <jeremy.gow@gmail.com>
date Mon, 21 Jan 2013 11:08:11 +0000
parents f99fd6a7bbfc
children
rev   line source
j@310 1 (cl:in-package #:amuse-midi-db)
j@310 2
j@310 3 (defclass midi-db-object (amuse-object) ())
j@310 4
j@310 5 (defclass midi-db-identifier (identifier midi-db-object) ())
j@310 6
j@310 7 (defclass midi-db-collection-identifier (midi-db-identifier)
j@310 8 ((collection-id :initarg :collection-id
j@310 9 :accessor collection-id
j@310 10 :initform nil))
j@310 11 (:documentation "Class to represent midi-db collection identifiers."))
j@310 12
j@310 13 (defun make-midi-db-collection-identifier (collection-id)
j@310 14 (make-instance 'midi-db-collection-identifier
j@310 15 :collection-id collection-id))
j@310 16
j@310 17 (defclass midi-db-composition-identifier (composition-identifier
j@310 18 midi-db-identifier)
j@310 19 ((composition-id :reader composition-id
j@310 20 :initarg :composition-id))
j@310 21 (:documentation "Class to represent midi-db composition identifiers."))
j@310 22
j@310 23 (defun make-midi-db-composition-identifier (composition-id)
j@310 24 (make-instance 'midi-db-composition-identifier
j@310 25 :composition-id composition-id))
j@310 26
j@310 27 (defclass midi-db-composition (midi-composition midi-db-object)
j@310 28 ((collection-identifier :initarg :collection-identifier
j@310 29 :reader collection-identifier)
j@310 30 (filename :initarg :filename
j@310 31 :reader filename)
j@310 32 (owner :initarg :owner
j@310 33 :reader owner)
j@310 34 (version :initarg :version
j@310 35 :reader version)
j@310 36 (creation-timestamp :initarg :creation-timestamp
j@310 37 :reader creation-timestamp)
j@310 38 (deletion-timestamp :initarg :deletion-timestamp
j@310 39 :reader deletion-timestamp))
j@310 40 (:documentation "Midi-db class with slots for additional database
j@310 41 fields. FIXME: This should perhaps be a subclass of 'versioned
j@310 42 constituents'?"))
j@310 43
j@310 44 (defun make-midi-db-composition (events start duration tempi timesigs
j@310 45 keysigs identifier
j@310 46 collection-identifier timebase
j@310 47 filename owner version
j@310 48 creation-timestamp
j@310 49 deletion-timestamp)
j@310 50 "Make a midi-db composition. This does not do the usual
j@310 51 adjust-sequence initialisation (calling
j@310 52 %recompute-standard-composition-period). FIXME: Is this bad?"
j@310 53 (make-instance 'midi-db-composition
j@310 54 :%data events
j@310 55 :time start
j@310 56 :interval duration
j@310 57 :time-signatures timesigs
j@310 58 :tempi tempi
j@310 59 :key-signatures keysigs
j@310 60 :identifier identifier
j@310 61 :collection-identifier collection-identifier
j@310 62 :midi-timebase timebase
j@310 63 :filename filename
j@310 64 :owner owner
j@310 65 :version version
j@310 66 :creation-timestamp creation-timestamp
j@310 67 :deletion-timestamp deletion-timestamp))
j@310 68
j@310 69 (defmethod initialize-instance :after ((composition
j@310 70 midi-db-composition) &key)
j@310 71 "Initialize each event so that it knows what composition it belongs
j@310 72 to."
j@310 73 (sequence:dosequence (e composition t)
j@310 74 (%set-composition composition e)))
j@310 75
j@310 76 (defclass midi-db-event (midi-db-object linked-event)
j@310 77 ((collection-identifier :initarg :collection-identifier
j@310 78 :reader collection-identifier)
j@310 79 (composition-identifier :initarg :composition-identifier
j@310 80 :reader composition-identifier)
j@310 81 (identifier :initarg :identifier
j@310 82 :reader identifier)
j@310 83 (version :initarg :version
j@310 84 :reader version)))
j@310 85
j@310 86 (defclass midi-db-pitched-event (midi-pitched-event midi-db-event)
j@310 87 ()
j@310 88 (:documentation "Midi-db class with slots for additional database
j@310 89 fields. FIXME: This should perhaps be a subclass of 'versioned
j@310 90 constituents'?"))
j@310 91
j@310 92 (defclass midi-db-percussive-event (midi-percussive-event midi-db-event)
j@310 93 ()
j@310 94 (:documentation "Midi-db class with slots for additional database
j@310 95 fields. FIXME: This should perhaps be a subclass of 'versioned
j@310 96 constituents'?"))
j@310 97
j@310 98 (defun make-midi-db-pitched-event (collection-identifier
j@310 99 composition-identifier
j@310 100 event-identifier track channel
j@310 101 patch pitch velocity start duration
j@310 102 version &optional composition)
j@310 103 (make-instance 'midi-db-pitched-event
j@310 104 :collection-identifier collection-identifier
j@310 105 :composition-identifier composition-identifier
j@310 106 :identifier event-identifier
j@310 107 :track track
j@310 108 :channel channel
j@310 109 :patch patch
j@310 110 :number pitch
j@310 111 :velocity velocity
j@310 112 :time start
j@310 113 :interval duration
j@310 114 :version version
j@310 115 :composition composition))
j@310 116
j@310 117 (defun make-midi-db-percussive-event (collection-identifier
j@310 118 composition-identifier
j@310 119 event-identifier track channel
j@310 120 patch drum-sound velocity start
j@310 121 duration version &optional
j@310 122 composition)
j@310 123 (make-instance 'midi-db-percussive-event
j@310 124 :collection-identifier collection-identifier
j@310 125 :composition-identifier composition-identifier
j@310 126 :identifier event-identifier
j@310 127 :track track
j@310 128 :channel channel
j@310 129 :patch patch
j@310 130 :sound drum-sound
j@310 131 :velocity velocity
j@310 132 :time start
j@310 133 :interval duration
j@310 134 :version version
j@310 135 :composition composition))
j@310 136
j@310 137 (defclass midi-db-tempi (standard-tempo-period midi-db-object)
j@310 138 ((version :initarg :version
j@310 139 :reader version))
j@310 140 (:documentation "FIXME: subclass versioned constituent"))
j@310 141
j@310 142 (defun make-midi-db-tempo (start duration microsecs-per-crotchet version)
j@310 143 (make-instance 'midi-db-tempi
j@310 144 :time start
j@310 145 :interval duration
j@310 146 :bpm (microsecond-per-crotchet-to-bpm
j@310 147 microsecs-per-crotchet)
j@310 148 :version version))
j@310 149
j@310 150 (defclass midi-db-timesig (standard-time-signature-period
j@310 151 midi-db-object)
j@310 152 ((version :initarg :version
j@310 153 :reader version))
j@310 154 (:documentation "FIXME: subclass versioned constituent"))
j@310 155
j@310 156 (defun make-midi-db-timesig (start duration numerator denominator
j@310 157 version)
j@310 158 (make-instance 'midi-db-timesig
j@310 159 :time start
j@310 160 :interval duration
j@310 161 :numerator numerator
j@310 162 :denominator denominator
j@310 163 :version version))
j@310 164
j@310 165 (defclass midi-db-keysig (midi-key-signature-period
j@310 166 midi-db-object)
j@310 167 ((version :initarg :version
j@310 168 :reader version))
j@310 169 (:documentation "FIXME: subclass versioned constituent"))
j@310 170
j@310 171 (defun make-midi-db-keysig (start duration mode sharp-count version)
j@310 172 (make-instance 'midi-db-keysig
j@310 173 :time start
j@310 174 :interval duration
j@310 175 :mode mode
j@310 176 :sharp-count sharp-count
j@310 177 :version version))