c@43
|
1 (in-package "AMUSE-TABCODE")
|
c@43
|
2
|
c@43
|
3 (defmethod tempi ((composition tabcode-composition))
|
c@43
|
4 ())
|
c@43
|
5 (defmethod time-signatures ((composition tabcode-composition))
|
d@181
|
6 (metrical-signs composition))
|
c@43
|
7
|
d@179
|
8 (defmethod get-applicable-key-signatures (object (composition tabcode-composition))
|
d@179
|
9 ())
|
d@179
|
10
|
d@179
|
11 (defmethod crotchet ((object tabcode-object))
|
d@179
|
12 (make-standard-period 1))
|
d@179
|
13
|
d@179
|
14 (defmethod current-bar ((moment standard-moment) (composition tabcode-composition))
|
d@179
|
15 (find-if #'(lambda (x) (and (time< moment (cut-off x))
|
d@179
|
16 (time>= moment (onset x))))
|
d@179
|
17 (tabcode-bars composition)))
|
d@179
|
18
|
d@179
|
19 (defmethod current-beat ((moment standard-moment) (composition tabcode-composition))
|
d@179
|
20 ;; clearly broken, but can unbreak unusual cases as they arise (?!)
|
d@179
|
21 (let ((bar (current-bar moment composition))
|
d@179
|
22 (metre (find-if #'(lambda (x) (and (time< moment (cut-off x))
|
d@179
|
23 (time>= moment (onset x))))
|
d@179
|
24 (metrical-signs composition))))
|
d@179
|
25 (unless (and bar metre)
|
d@179
|
26 (error 'insufficient-information
|
d@179
|
27 :operation 'beat-period
|
d@179
|
28 :datatype (class-of composition)))
|
d@179
|
29 (let ((beats-in-bar) (beat-duration))
|
d@179
|
30 (cond
|
d@179
|
31 ((ur metre)
|
d@179
|
32 ;; we have a weird compound signature, goodness knows what to
|
d@179
|
33 ;; do. This probably means that one of them is a proportion
|
d@179
|
34 ;; sign.
|
d@179
|
35 (error 'insufficient-information
|
d@179
|
36 :operation 'beat-period
|
d@179
|
37 :datatype (class-of composition)))
|
d@179
|
38 ((and (ll metre)
|
d@179
|
39 (numberp (ll metre)) ;; we have a `standard
|
d@179
|
40 (numberp (ul metre)));; time sig'
|
d@179
|
41 (setf beats-in-bar (ul metre)
|
d@179
|
42 beat-duration (/ 4 (ll metre)))
|
d@179
|
43 (when (and (> beats-in-bar 3)
|
d@179
|
44 (= (rem beats-in-bar 3) 0))
|
d@179
|
45 (setf beats-in-bar (/ beats-in-bar 3)
|
d@179
|
46 beat-duration (* beat-duration 3))))
|
d@179
|
47 ((and (null (ll metre))
|
d@179
|
48 (numberp (ul metre)))
|
d@179
|
49 (setf beats-in-bar (ul metre))
|
d@179
|
50 (do ((proportion 4 (/ proportion 2)))
|
d@179
|
51 ((= (rem (/ (duration bar) proportion)
|
d@179
|
52 beats-in-bar) 0)
|
d@179
|
53 (setf beat-duration proportion))))
|
d@179
|
54 ((null (ll metre))
|
d@179
|
55 (cond
|
d@179
|
56 ((string= (ul metre) "C")
|
d@179
|
57 (setf beats-in-bar 4)
|
d@179
|
58 (setf beat-duration 1))
|
d@179
|
59 ((string= (ul metre) "C/")
|
d@179
|
60 (setf beats-in-bar 2)
|
d@179
|
61 (setf beat-duration 2)))))
|
d@179
|
62 (unless (= (rem (duration bar)
|
d@179
|
63 (* beat-duration beats-in-bar))
|
d@179
|
64 0)
|
d@179
|
65 (error "Bar length doesn't match metrical symbol, I think"))
|
d@179
|
66 (let ((beat-period (make-standard-anchored-period
|
d@179
|
67 (timepoint bar) beat-duration)))
|
d@179
|
68 (do ()
|
d@179
|
69 ((time> (cut-off beat-period) moment) beat-period)
|
d@179
|
70 (setf (timepoint beat-period)
|
d@179
|
71 (timepoint (cut-off beat-period))))))))
|
d@179
|
72 |