m@24
|
1 (cl:in-package #:amuse)
|
m@24
|
2
|
j@287
|
3 ;;; Identifiers
|
j@287
|
4
|
j@287
|
5 (defgeneric identifier (object))
|
j@287
|
6
|
j@287
|
7 (defgeneric event-id (object))
|
j@287
|
8
|
j@287
|
9 (defgeneric composition-id (object))
|
j@287
|
10
|
m@24
|
11 ;;; Pulling compositions from the database
|
m@24
|
12
|
d@123
|
13 (defgeneric get-composition (identifier)
|
d@123
|
14 (:documentation "Returns a composition of type dependant on
|
d@123
|
15 identifier"))
|
m@24
|
16
|
d@169
|
17 (defgeneric get-constituents (constituent-identifier)
|
d@169
|
18 (:documentation "Returns a list of constituents matching the
|
d@169
|
19 criteria in identifier"))
|
d@169
|
20
|
m@89
|
21 (defgeneric monody (object)
|
m@89
|
22 (:documentation "Returns a monody."))
|
m@89
|
23 (defgeneric ensure-monody (object)
|
m@89
|
24 (:documentation "Returns a generalised boolean."))
|
m@89
|
25
|
d@33
|
26 ;;; Getting constituents from compositions
|
d@33
|
27 ;; IS this the mechanism we want to use
|
d@72
|
28 (defgeneric time-signatures (composition)
|
d@72
|
29 (:documentation "Returns all time-signatures in a composition
|
d@72
|
30 Probably shouldn't be exported - can be replaced
|
d@72
|
31 by (get-applicable-time-signature commposition composition)"))
|
d@72
|
32 (defgeneric (setf time-signatures) (sequence composition)
|
d@72
|
33 (:documentation "Sets all time-signatures in a composition.
|
d@72
|
34 Is this wanted here?"))
|
d@72
|
35 (defgeneric tempi (composition)
|
d@72
|
36 (:documentation "Returns all tempi in a composition Probably
|
d@72
|
37 shouldn't be exported - can be replaced
|
d@72
|
38 by (get-applicable-tempi commposition composition)"))
|
d@72
|
39 (defgeneric (setf tempi) (sequence composition)
|
d@72
|
40 (:documentation "Sets all tempi in a composition.
|
d@72
|
41 Is this wanted here?"))
|
d@72
|
42 (defgeneric key-signatures (composition)
|
d@72
|
43 (:documentation "Returns all key-signatures in a composition
|
d@72
|
44 Probably shouldn't be exported - can be replaced
|
d@72
|
45 by (get-applicable-key-signature commposition composition)"))
|
d@72
|
46 (defgeneric (setf key-signatures) (sequence composition)
|
d@72
|
47 (:documentation "Sets all key sigs in a composition.
|
d@72
|
48 Is this wanted here?"))
|
d@33
|
49
|
m@24
|
50 ;;; Simple Accessors
|
m@24
|
51
|
m@24
|
52 ;; pitch-based
|
m@24
|
53
|
m@24
|
54 (defgeneric pitch (object &key kind)) ; ? Maybe this returns the pitch
|
m@24
|
55 ; in its ur form?
|
d@136
|
56 (defgeneric chromatic-pitch (pitch))
|
d@136
|
57 (defgeneric diatonic-pitch (pitch))
|
m@24
|
58 (defgeneric frequency (object)) ;?
|
m@81
|
59
|
d@136
|
60 (defgeneric octave (pitch)
|
m@86
|
61 (:documentation "Return an integer representing the octave of
|
d@136
|
62 pitch where middle c is defined to be the lowest pitch in
|
m@86
|
63 octave 4."))
|
m@86
|
64
|
d@136
|
65 (defgeneric diatonic-pitch-octave (pitch)
|
c@106
|
66 (:documentation "Return an integer representing the diatonic octave
|
d@136
|
67 of pitch."))
|
c@106
|
68
|
d@136
|
69 (defgeneric diatonic-pitch-accidental (pitch)
|
m@86
|
70 (:documentation "Return an integer representing the inflection of a
|
m@86
|
71 diatonic pitch where where negative values indicate numbers of flats,
|
m@86
|
72 0 indicates natural and positive values indicate numbers of sharps."))
|
m@86
|
73
|
d@136
|
74 (defgeneric diatonic-pitch-mp (pitch)
|
c@108
|
75 (:documentation "Return an integer representing the morphetic pitch
|
c@108
|
76 \(in MIPS terms) of a diatonic pitch."))
|
d@136
|
77 (defgeneric diatonic-pitch-cp (pitch)
|
c@108
|
78 (:documentation "Return an integer representing the chromatic pitch
|
c@108
|
79 \(in MIPS terms) of a diatonic pitch."))
|
c@108
|
80
|
d@136
|
81 (defgeneric middle-c (pitch)
|
m@81
|
82 (:documentation "Returns the value of middle C in the particular
|
d@136
|
83 representation of pitch used by PITCH."))
|
d@136
|
84 (defgeneric midi-pitch-number (pitch)
|
d@136
|
85 (:documentation "Takes a pitch (usually a pitched event) and
|
d@136
|
86 returns an integer between 0 and 127 representing the chromatic
|
d@136
|
87 pitch represented (60=middle C, 48 the C below that, etc.)"))
|
d@136
|
88 (defgeneric asa-pitch-string (pitch)
|
m@81
|
89 (:documentation "Returns a string representing the designated ASA
|
m@81
|
90 pitch name which has three parts: a letter name in the set
|
m@81
|
91 {A,B,C,D,E,F,G}, an inflection in the set {n,f,s,ff,ss,fff,sss,...}
|
m@81
|
92 and an octave number. E.g., Cn4 = Middle C."))
|
d@136
|
93 (defgeneric asa-interval-string (pitch)
|
c@112
|
94 (:documentation "Returns a string representing the designated ASA
|
c@112
|
95 interval name which has two or three parts: a direction in the set
|
c@112
|
96 {r,f} (absent for unisons/primes), a type in the set
|
c@112
|
97 {p,ma,mi,a,d,aa,dd,aaa,ddd,...}, and a size number. E.g. rma2 =
|
c@112
|
98 rising major second."))
|
d@136
|
99 (defgeneric diatonic-pitch-name (pitch)
|
m@81
|
100 (:documentation "Returns a char in the set
|
m@81
|
101 {#\A,#\B,#\C,#\D,#\E,#\F,#\G}, representing the pitch name of
|
d@136
|
102 PITCH."))
|
d@136
|
103 (defgeneric pitch-class (pitch)
|
d@136
|
104 (:documentation "Takes a pitch (usually a pitched event) and
|
d@136
|
105 returns an integer between 0 and 12 representing the
|
d@136
|
106 octave-independant pitch, with c=0, c#=1, etc.")
|
m@24
|
107 (:method (p) (mod (midi-pitch-number p) 12)))
|
d@136
|
108 (defgeneric span (pitch-interval))
|
m@24
|
109
|
m@24
|
110 ;; time
|
m@24
|
111
|
d@136
|
112 (defgeneric duration (period)
|
d@136
|
113 (:documentation "Returns a real. Probably should only apply do
|
d@136
|
114 standard-periods (rather than periods? or should it return
|
d@136
|
115 something other than a value in other cases)"))
|
d@136
|
116 (defgeneric (setf duration) (value period)
|
d@136
|
117 (:documentation "As with duration, perhaps this should work only
|
d@136
|
118 with standard-periods"))
|
d@136
|
119 (defgeneric timepoint (moment)
|
d@136
|
120 (:documentation "Returns a number for a moment. Does this make
|
d@136
|
121 any sense on an abstrace class? Should it just apply to
|
d@136
|
122 standard-moment?"))
|
d@136
|
123 (defgeneric (setf timepoint) (value moment)
|
d@136
|
124 (:documentation "Sets timepoint. What does this mean for an
|
d@136
|
125 abstract class? Should it just apply to standard-moment"))
|
d@136
|
126 (defgeneric cut-off (anchored-period) ; name?
|
d@72
|
127 (:documentation "Returns a <moment> representing the point at
|
d@121
|
128 which the anchored period has ended. By default, is calculated
|
d@121
|
129 as the result of running time+ on the onset and period of the
|
d@121
|
130 object.")
|
d@136
|
131 (:method (apd) (time+ (moment apd) (period apd))))
|
d@136
|
132 (defgeneric crotchet (object)
|
m@95
|
133 (:documentation "Returns a period, the duration of which represents
|
m@95
|
134 a crotchet in the time representation used by object."))
|
m@24
|
135
|
m@24
|
136 ;; others
|
m@24
|
137
|
m@24
|
138 ;; I've given the time-sig accessors general names because it allows
|
m@24
|
139 ;; for symbols in time-signatures as well as numbers - numerator is an
|
m@24
|
140 ;; odd accessor if the time sig is C (even in common practice) but
|
d@100
|
141 ;; its meaning is clear. beat-units-per-bar is clearer, though, I
|
m@24
|
142 ;; think.
|
m@24
|
143
|
d@123
|
144 (defgeneric beat-units-per-bar (time-signature)
|
d@123
|
145 (:documentation "In a standard, fraction-like time-signature or
|
d@123
|
146 a symbolic equivalent, this is the numerator."))
|
m@24
|
147 (defgeneric time-signature-numerator (time-signature)
|
d@123
|
148 (:method (ts) (beat-units-per-bar ts))
|
d@123
|
149 (:documentation "Not obviously meaningful for non fraction-like
|
d@123
|
150 time signatures"))
|
d@123
|
151 (defgeneric beat-units (time-signature)
|
d@123
|
152 (:documentation "In a standard, fraction-like time-signature or
|
d@134
|
153 a symbolic equivalent, this is the denominator (n.b. the
|
d@134
|
154 difference between this and @code{tactus-duration} is only
|
d@134
|
155 visible for compound time, where this returns the lower portion
|
d@134
|
156 of the time signature, but @code{tactus-duration} returns the
|
d@134
|
157 higher-level unit)."))
|
m@24
|
158 (defgeneric time-signature-denominator (time-signature)
|
d@123
|
159 (:method (ts) (beat-units ts))
|
d@123
|
160 (:documentation "Not obviously meaningful for non fraction-like
|
d@123
|
161 time signatures"))
|
d@33
|
162 (defgeneric tactus-duration (time-signature)
|
j@305
|
163 ;; basic, but should do? NO! This defines 6/4 as compound. We need
|
j@305
|
164 ;; proper simplep and compoundp predicates.
|
d@33
|
165 (:method (ts)
|
j@305
|
166 (warn "FIXME: tactus-duration is broken")
|
d@33
|
167 (cond
|
j@305
|
168 ;; ((and (not (= (beat-units-per-bar ts) 3))
|
j@305
|
169 ;; (= (rem (beat-units-per-bar ts) 3) 0))
|
j@305
|
170 ((and (= (beat-units ts) 8)
|
d@33
|
171 (= (rem (beat-units-per-bar ts) 3) 0))
|
d@33
|
172 ;; compound time
|
d@33
|
173 (* (/ 4 (beat-units ts))
|
d@33
|
174 3))
|
d@123
|
175 (t (/ 4 (beat-units ts)))))
|
d@123
|
176 (:documentation "Returns a number of crotchets to represent the
|
d@123
|
177 tactus, based on some idea of time signature patterns. Should,
|
d@123
|
178 in future, return a duration rather than a number."))
|
m@24
|
179
|
d@123
|
180 (defgeneric key-signature-sharps (key-signature)
|
d@123
|
181 (:documentation "Simple query for normal key-signatures."))
|
d@123
|
182 (defgeneric key-signature-mode (ks)
|
d@123
|
183 (:documentation "Query that only makes sense for midi-like key
|
d@123
|
184 signatures"))
|
m@24
|
185
|
d@123
|
186 (defgeneric bpm (tempo)
|
d@123
|
187 (:documentation "Basic tempo query")) ;; in bpm
|
m@24
|
188 (defgeneric microseconds-per-crotchet (tempo)
|
m@24
|
189 ;; As used (when rounded) in MIDI
|
d@123
|
190 (:method (tp) (/ 60000000 (bpm tp)))
|
d@123
|
191 (:documentation "Basic tempo query for MIDI. N.B. This will be
|
d@123
|
192 a fraction and must be rounded before being used for output."))
|
m@24
|
193
|
m@24
|
194 ;;; Coerce-type accessors
|
m@24
|
195
|
m@24
|
196 ;; Should I be including these default methods? Should the accessors
|
m@24
|
197 ;; be direct slot accessors or the generics I'm using? Should we
|
m@24
|
198 ;; return the object itself if it already is in the target class?
|
m@24
|
199
|
d@136
|
200 (defgeneric anchored-period (anchored-period)
|
d@123
|
201 (:method (apd) (make-anchored-period (onset apd) (duration apd)))
|
d@123
|
202 (:documentation "Coerce any anchored period to a plain anchored
|
d@123
|
203 period"))
|
m@24
|
204
|
d@136
|
205 (defgeneric period (period)
|
d@136
|
206 (:method (pd) (make-period (duration pd)))
|
d@123
|
207 (:documentation "Coerce any period to a floating period"))
|
m@24
|
208
|
d@136
|
209 (defgeneric moment (moment)
|
d@123
|
210 (:method (md) (make-moment (timepoint md)))
|
d@136
|
211 (:documentation "Coerce any moment, including an
|
d@123
|
212 anchored-period to a moment"))
|
m@24
|
213
|
d@136
|
214 (defgeneric onset (anchored-period)
|
d@139
|
215 (:method (ap) (moment ap))
|
d@123
|
216 (:documentation "Return a moment for the start of an anchored period"))
|
d@136
|
217 (defgeneric (setf onset) (value anchored-period))
|
m@24
|
218
|
m@24
|
219 ;;; Time Protocol (or moments?)
|
m@24
|
220
|
m@24
|
221 ;; negative times/durations -> ERROR?
|
m@24
|
222
|
m@24
|
223 ;; time+: <time> <duration> -> <time>
|
m@24
|
224 ;; <duration> <time> -> <time> (same as previous?)
|
m@24
|
225 ;; <duration> <duration> -> <duration> (or a distinct duration+?)
|
m@24
|
226 ;; <time> <time> -> ERROR?
|
m@24
|
227 ;;
|
m@24
|
228 ;; time-: <time> <time> -> <duration>
|
m@24
|
229 ;; <time> <duration> -> <time>
|
m@24
|
230 ;; <duration> <duration> -> <duration> (or a distinct duration-?)
|
m@24
|
231 ;; <duration> <time> -> ERROR?
|
m@24
|
232 ;; <anchored> <anchored> -> (time- (moment o1) (moment o2)) ? or error?
|
m@24
|
233
|
d@102
|
234 (defgeneric time+ (object1 object2)
|
d@136
|
235 (:documentation "Addition for time objects"))
|
d@102
|
236 (defgeneric time- (object1 object2)
|
d@136
|
237 (:documentation "Subtraction for time objects"))
|
m@24
|
238
|
d@102
|
239 (defgeneric time> (object1 object2)
|
d@136
|
240 (:documentation "> operator for moments"))
|
m@24
|
241 (defgeneric time< (object1 object2)
|
d@136
|
242 (:documentation "< operator for moments")
|
m@24
|
243 (:method (o1 o2) (time> o2 o1)))
|
d@102
|
244 (defgeneric time= (object1 object2)
|
d@136
|
245 (:documentation "= operator for moments"))
|
m@24
|
246 (defgeneric time>= (object1 object2)
|
d@136
|
247 (:documentation ">= operator for moments")
|
m@24
|
248 (:method (o1 o2) (or (time> o1 o2) (time= o1 o2))))
|
m@24
|
249 (defgeneric time<= (object1 object2)
|
d@136
|
250 (:documentation "<= operator for moments")
|
m@24
|
251 (:method (o1 o2) (or (time< o1 o2) (time= o1 o2))))
|
m@24
|
252 (defgeneric time/= (object1 object2)
|
d@136
|
253 (:documentation "not = operator for moments")
|
m@24
|
254 (:method (o1 o2) (not (time= o1 o2))))
|
m@24
|
255
|
m@24
|
256 ;;; Duration protocol
|
m@24
|
257
|
d@118
|
258 (defgeneric duration> (object1 object2)
|
d@136
|
259 (:documentation "> operator for periods"))
|
m@24
|
260 (defgeneric duration< (object1 object2)
|
d@136
|
261 (:documentation "< operator for periods")
|
m@24
|
262 (:method (o1 o2) (duration> o2 o1)))
|
d@118
|
263 (defgeneric duration= (object1 object2)
|
d@136
|
264 (:documentation "= operator for periods"))
|
m@24
|
265 (defgeneric duration>= (object1 object2)
|
d@136
|
266 (:documentation ">= operator for periods")
|
m@24
|
267 (:method (o1 o2) (or (duration> o1 o2) (duration= o1 o2))))
|
m@24
|
268 (defgeneric duration<= (object1 object2)
|
d@136
|
269 (:documentation "<= operator for periods")
|
m@24
|
270 (:method (o1 o2) (or (duration< o1 o2) (duration= o1 o2))))
|
m@24
|
271 (defgeneric duration/= (object1 object2)
|
d@136
|
272 (:documentation "not = operator for periods")
|
m@24
|
273 (:method (o1 o2) (not (duration= o1 o2))))
|
m@24
|
274
|
m@24
|
275 ;; for linear scaling:
|
d@118
|
276 (defgeneric duration* (object1 object2)
|
d@136
|
277 (:documentation "Multiplication operator for
|
d@136
|
278 periods. Intuitively, this makes sense, but it may cause us
|
d@118
|
279 trouble with some implementations in the future."))
|
d@118
|
280 (defgeneric duration/ (object1 number)
|
d@136
|
281 (:documentation "Division operator for periods. This may turn
|
d@136
|
282 out not to mean much. Division is probably useful, but we may
|
d@136
|
283 need to define what we mean with care."))
|
m@24
|
284
|
m@24
|
285 ;;; Pitch protocol
|
m@24
|
286
|
m@24
|
287 ;; pitch+: <pitch> <pitch> -> ERROR
|
m@24
|
288 ;; <pitch> <interval> -> <pitch>
|
m@24
|
289 ;; <interval> <pitch> -> <pitch> (same as previous?)
|
m@24
|
290 ;; <interval> <interval> -> <interval> (or a distinct interval+?)
|
m@24
|
291 ;;
|
m@24
|
292 ;; pitch-: <pitch> <pitch> -> <interval>
|
m@24
|
293 ;; <pitch> <interval> -> <pitch>
|
m@24
|
294 ;; <interval> <interval> -> <interval>
|
m@24
|
295 ;; <interval> <pitch> -> ERROR
|
m@24
|
296
|
m@24
|
297 (defgeneric pitch+ (object1 object2))
|
m@24
|
298 (defgeneric pitch- (object1 object2))
|
m@24
|
299
|
m@24
|
300 (defgeneric pitch> (object1 object2))
|
m@24
|
301 (defgeneric pitch< (object1 object2)
|
m@24
|
302 (:method (o1 o2) (pitch> o2 o1)))
|
m@24
|
303 (defgeneric pitch= (object1 object2))
|
m@24
|
304 (defgeneric pitch>= (object1 object2)
|
m@24
|
305 (:method (o1 o2) (or (pitch> o1 o2) (pitch= o1 o2))))
|
m@24
|
306 (defgeneric pitch<= (object1 object2)
|
m@24
|
307 (:method (o1 o2) (or (pitch< o1 o2) (pitch= o1 o2))))
|
m@24
|
308 (defgeneric pitch/= (object1 object2)
|
m@24
|
309 (:method (o1 o2) (not (pitch= o1 o2))))
|
m@24
|
310
|
m@24
|
311 ;;; Interval protocol (emphasise _pitch_ not _time_ interval?)
|
m@24
|
312
|
m@24
|
313 (defgeneric interval> (object1 object2))
|
m@24
|
314 (defgeneric interval< (object1 object2)
|
m@24
|
315 (:method (o1 o2) (interval> o2 o1)))
|
m@24
|
316 (defgeneric interval= (object1 object2))
|
m@24
|
317 (defgeneric interval>= (object1 object2)
|
m@24
|
318 (:method (o1 o2) (or (interval> o1 o2) (interval= o1 o2))))
|
m@24
|
319 (defgeneric interval<= (object1 object2)
|
m@24
|
320 (:method (o1 o2) (or (interval< o1 o2) (interval= o1 o2))))
|
m@24
|
321 (defgeneric interval/= (object1 object2)
|
m@24
|
322 (:method (o1 o2) (not (interval= o1 o2))))
|
m@24
|
323
|
m@24
|
324 ;;; Allen's (1984) interval relations
|
m@24
|
325 ;;; . equals already defined as INTERVAL= above
|
m@24
|
326 ;;; . inverses ommitted for now (just use CL:NOT)
|
m@24
|
327 ;;; . can all be defined in terms of MEETS (apparently)
|
m@24
|
328
|
m@24
|
329 (defgeneric meets (object1 object2))
|
m@24
|
330 (defgeneric before (object1 object2))
|
m@24
|
331 (defgeneric overlaps (object1 object2))
|
m@24
|
332 (defgeneric during (object1 object2))
|
m@24
|
333 (defgeneric starts (object1 object2))
|
m@24
|
334 (defgeneric ends (object1 object2))
|
m@24
|
335
|
m@24
|
336 ;;; and extensions thereof ...
|
m@24
|
337
|
m@24
|
338 (defgeneric subinterval (object1 object2)
|
m@24
|
339 (:method (o1 o2) (or (starts o1 o2) (during o1 o2) (ends o1 o2))))
|
m@24
|
340
|
m@24
|
341 (defgeneric disjoint (object1 object2)
|
m@24
|
342 (:method (o1 o2)
|
m@24
|
343 (or (before o1 o2) (meets o1 o2) (meets o2 o1) (before o2 o1))))
|
m@24
|
344
|
m@24
|
345 ;;; More time-based functions
|
d@33
|
346
|
d@33
|
347 (defgeneric period= (object1 object2)
|
d@33
|
348 (:method (x y) nil))
|
d@33
|
349
|
d@33
|
350 (defgeneric find-overlapping (anchored-period sequence)
|
d@33
|
351 ;; Returns all members of a sequence of period signifiers that overlap
|
d@33
|
352 ;; with the supplied period
|
d@33
|
353 (:method (ap s) (remove-if #'(lambda (x) (amuse:disjoint ap x)) s)))
|
d@33
|
354
|
m@24
|
355 ;; Return the anchored-period representing the intersection of two
|
d@136
|
356 ;; anchored-period.
|
d@136
|
357 (defgeneric period-intersection (anchored-period1
|
d@136
|
358 anchored-period2))
|
m@24
|
359
|
d@136
|
360 (defgeneric inter-onset-interval (moment1 moment2)
|
d@136
|
361 (:method (moment1 moment2) (time- (moment moment2) (moment moment1))))
|
m@24
|
362
|
m@24
|
363
|
m@24
|
364 ;;; Time Signature
|
m@24
|
365
|
d@33
|
366 (defgeneric get-applicable-time-signatures (anchored-period composition)
|
d@123
|
367 (:method (ap c) (find-overlapping ap (time-signatures c)))
|
d@136
|
368 (:documentation "Return a list of TIME-SIGNATURE-PERIODs that are
|
d@123
|
369 relevant to <anchored-period>. The period may contain
|
d@123
|
370 information such as staff position and voicing, and the method
|
d@123
|
371 may use this to filter its response"))
|
m@24
|
372
|
d@123
|
373 (defgeneric time-signature-equal (ts1 ts2)
|
d@123
|
374 (:documentation "Comparison operator. The definition of
|
d@123
|
375 equality is left open for implementers"))
|
m@67
|
376
|
m@24
|
377 ;;; Tempo
|
m@24
|
378
|
d@33
|
379 (defgeneric get-applicable-tempi (anchored-period composition)
|
d@123
|
380 (:method (ap c) (find-overlapping ap (tempi c)))
|
d@136
|
381 (:documentation "Return a list of TEMPO-PERIODs that are
|
d@136
|
382 relevant to <anchored-period>. The period may contain
|
d@136
|
383 information such as staff position and voicing, and the method
|
d@136
|
384 may use this to filter its response"))
|
m@24
|
385
|
d@123
|
386 (defgeneric tempo-equal (t1 t2)
|
d@123
|
387 (:documentation "Comparison operator. The definition of
|
d@123
|
388 equality is left open for implementers"))
|
m@67
|
389
|
m@24
|
390 ;;; Tonality (Key Signature / Mode)
|
m@24
|
391
|
d@123
|
392 (defgeneric get-applicable-key-signatures (object1 object2)
|
d@136
|
393 (:documentation "Return a list of KEY-SIGNATURE-PERIODs that are
|
d@123
|
394 relevant to <anchored-period>. The period may contain
|
d@123
|
395 information such as staff position and voicing, and the method
|
d@123
|
396 may use this to filter its response"))
|
m@24
|
397
|
d@123
|
398 (defgeneric key-signature-equal (ks1 ks2)
|
d@123
|
399 (:documentation "Comparison operator. The definition of
|
d@123
|
400 equality is left open to implementers"))
|
m@67
|
401
|
d@136
|
402 ;;; Some generic constructors - are these useful? (DL 31/8/07)
|
d@136
|
403 (defgeneric make-moment (value)
|
d@136
|
404 (:documentation "Returns MOMENT of subclass appropriate to the
|
d@136
|
405 class of value. Probably guessed."))
|
d@136
|
406 (defgeneric make-period (value)
|
d@136
|
407 (:documentation "Returns PERIOD of subclass appropriate to the
|
d@136
|
408 class of value. Probably guessed."))
|
d@136
|
409 (defgeneric make-anchored-period (start-value duration-value)
|
d@136
|
410 (:documentation "Returns ANCHORED-PERIOD of subclass
|
d@136
|
411 appropriate to the class of value. Probably guessed."))
|
d@136
|
412
|
d@160
|
413 (defgeneric trim-enclosing-silence (composition)
|
d@156
|
414 (:documentation "Returns a composition of the same type as
|
d@156
|
415 composition provided, with leading and following silences/rests
|
d@156
|
416 removed, but preserving all relevant information. Where
|
d@156
|
417 relevant, any silence in a bar containing musical material may
|
d@160
|
418 be preserved."))
|
d@136
|
419
|
m@24
|
420 ;;; Dynamics
|
m@24
|
421 ;;; Voice
|
m@81
|
422 ;;; Boundary Strength (phrasing)
|
d@175
|
423
|
d@175
|
424 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
d@175
|
425 ;;
|
d@175
|
426 ;; Experimental:
|
d@175
|
427 ;;
|
d@175
|
428
|
d@175
|
429 ;;; Proposed new metre functions
|
d@175
|
430 ;; These should provide sufficient functionality that the users need
|
d@175
|
431 ;; not refer to get-applicable-time-signatures unless they really mean
|
d@175
|
432 ;; it. In turn, this means that barline based representations have a
|
d@175
|
433 ;; better chance at guessing.
|
d@175
|
434
|
d@175
|
435 ;; Notes:
|
d@175
|
436 ;; * iteration is possible with
|
d@175
|
437 ;; (do ((beat (current-beat (make-moment 0) composition))
|
d@175
|
438 ;; (current-beat (cut-off beat) composition))) ...
|
d@175
|
439 ;; [That's probably not very efficient. there must be better ways]
|
d@175
|
440 ;; * gsharp and tabcode can answer bar questions, but not beat
|
d@175
|
441 ;; questions. Appropriate conditions and restarts will be needed.
|
d@175
|
442 ;; * a good test of this functionality will prob be amuse-harmony.
|
d@175
|
443
|
d@175
|
444 (defgeneric bar-period (time-signature implementation-object)
|
d@175
|
445 (:documentation "Returns a <period> with a duration equal to the
|
d@175
|
446 duration of a bar in the given time signature for the given
|
d@175
|
447 implementation. FIXME: this isn't guaranteed to be
|
d@175
|
448 meaningful (double time signatures break this"))
|
d@175
|
449 (defgeneric current-bar (moment composition)
|
d@175
|
450 (:documentation "Returns an <anchored-period> representing the
|
d@175
|
451 bar which contains moment"))
|
d@175
|
452
|
d@175
|
453 (defgeneric beat-period (moment time-signature implementation-object)
|
j@307
|
454 (:documentation "Takes a moment, time signature object and crotchet
|
j@307
|
455 and returns an <anchored-period> for the containing beat containing
|
j@307
|
456 moment. This is more useful when there's a complex time
|
j@307
|
457 signature (not currently possible) in which tactus is different in
|
j@307
|
458 different parts of the bar (e.g. 3+3+2/8)"))
|
d@175
|
459 (defgeneric current-beat (moment composition)
|
d@175
|
460 (:documentation "Returns an <anchored-period> representing the
|
d@175
|
461 tactus unit which contains moment"))
|
d@175
|
462
|
j@307
|
463 (defgeneric ioi-from-bar (moment)
|
j@307
|
464 (:documentation "Returns the IOI of moment (i.e. an event) from the
|
j@307
|
465 bar line."))
|
j@307
|
466
|
j@307
|
467 (defgeneric onset-in-bar (moment)
|
j@307
|
468 (:documentation "The position of moment in the bar, measured in
|
j@307
|
469 beats."))
|
d@175
|
470
|
d@175
|
471 ;;;;;;;;;;;;;;
|
d@175
|
472 ;;
|
d@175
|
473 ;;
|
d@175
|
474
|
d@175
|
475 (defgeneric get-applicable-clefs (anchored-period constituent))
|
j@276
|
476
|
j@320
|
477 ;;;=====================================================================
|
j@304
|
478 ;;; Copying events in time
|
j@320
|
479 ;;;=====================================================================
|
j@276
|
480
|
j@304
|
481 (defgeneric move-to-first-bar (composition))
|
j@276
|
482
|
j@278
|
483 (defgeneric copy-event (event))
|
j@278
|
484
|
j@278
|
485 (defgeneric voice (event))
|
j@304
|
486
|
j@304
|
487
|
j@320
|
488 ;;;=====================================================================
|
j@304
|
489 ;;; Searching for events
|
j@320
|
490 ;;;=====================================================================
|
j@304
|
491
|
j@304
|
492 (defgeneric find-next-event (source-event &key predicate test
|
j@304
|
493 break-test search-list))
|
j@304
|
494
|
j@320
|
495 ;;;=====================================================================
|
j@304
|
496 ;;; Sorting Compositions
|
j@320
|
497 ;;;=====================================================================
|
j@304
|
498
|
j@304
|
499 (defgeneric event< (event1 event2 attribute-list))
|
j@304
|
500
|
j@304
|
501 (defgeneric sort-composition (composition attribute-list))
|