comparison implementations/mtp/methods.lisp @ 96:fade42e8a087

implementations/mtp/: implement CROTCHET darcs-hash:20070724131529-c0ce4-5c6b749757ff12c1d2c878b95d18465bedc58102.gz
author Marcus Pearce <m.pearce@gold.ac.uk>
date Tue, 24 Jul 2007 14:15:29 +0100
parents 23c3be4c445f
children cb7576b21c8e
comparison
equal deleted inserted replaced
95:e99e51c2a8af 96:fade42e8a087
122 :initial-contents (sort events #'< :key #'amuse:timepoint)) 122 :initial-contents (sort events #'< :key #'amuse:timepoint))
123 monody)) 123 monody))
124 124
125 ;;; Constituents from compositions: time-signatures 125 ;;; Constituents from compositions: time-signatures
126 126
127 (defgeneric timebase (object)) 127 (defmethod crotchet ((dataset mtp-dataset))
128 128 (amuse:make-floating-period
129 (defmethod timebase ((dataset mtp-dataset)) 129 (/ (dataset-timebase dataset) 4)))
130 (dataset-timebase dataset))
131 130
132 #.(clsql:locally-enable-sql-reader-syntax) 131 #.(clsql:locally-enable-sql-reader-syntax)
133 (defmethod timebase ((composition mtp-composition)) 132 (defmethod crotchet ((composition mtp-composition))
134 (car (clsql:select [timebase] :from [mtp-dataset] 133 (let ((timebase
135 :where [= [dataset-id] 134 (car (clsql:select [timebase] :from [mtp-dataset]
136 (dataset-id composition)] 135 :where [= [dataset-id]
137 :flatp t 136 (dataset-id composition)]
138 :field-names nil))) 137 :flatp t
139 (defmethod timebase ((event mtp-event)) 138 :field-names nil))))
140 (car (clsql:select [timebase] :from [mtp-dataset] 139 (amuse:make-floating-period (/ timebase 4))))
141 :where [= [dataset-id] 140 (defmethod crotchet ((event mtp-event))
142 (dataset-id event)] 141 (let ((timebase
143 :flatp t 142 (car (clsql:select [timebase] :from [mtp-dataset]
144 :field-names nil))) 143 :where [= [dataset-id]
144 (dataset-id event)]
145 :flatp t
146 :field-names nil))))
147 (amuse:make-floating-period (/ timebase 4))))
145 #.(clsql:restore-sql-reader-syntax-state) 148 #.(clsql:restore-sql-reader-syntax-state)
146 149
147 (defmethod get-applicable-time-signatures ((e mtp-event) c) 150 (defmethod get-applicable-time-signatures ((e mtp-event) c)
148 (declare (ignore c)) 151 (declare (ignore c))
149 (let ((pulses (%mtp-pulses e)) 152 (let ((pulses (%mtp-pulses e))
150 (barlength (%mtp-barlength e)) 153 (barlength (%mtp-barlength e))
151 (timebase (timebase e))) 154 (timebase (* 4 (duration (crotchet e)))))
152 (list 155 (list
153 (amuse:make-basic-time-signature pulses 156 (amuse:make-basic-time-signature pulses
154 (/ timebase (/ barlength pulses)) 157 (/ timebase (/ barlength pulses))
155 (timepoint e) 158 (timepoint e)
156 (duration e))))) 159 (duration e)))))