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