j@215
|
1 (cl:in-package #:amuse-meredith)
|
j@215
|
2
|
j@215
|
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
j@215
|
4 ;;; Specialised constructors
|
j@215
|
5 (defmethod make-composition-identifier ((package (eql *package*))
|
j@215
|
6 composition-id)
|
j@215
|
7 (make-meredith-composition-identifier composition-id))
|
j@215
|
8
|
j@215
|
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
j@215
|
10 ;;; Compositions
|
j@215
|
11
|
j@215
|
12 (defvar *event-attributes*
|
j@215
|
13 #.(clsql:locally-enable-sql-reader-syntax)
|
j@215
|
14 (list [event-id] [tatum-on] [tatum-dur] [tactus-on] [tactus-dur]
|
j@215
|
15 [crot-on] [crot-dur] [tatum-on-ms] [tatum-dur-ms] [beat-on-ms]
|
j@215
|
16 [beat-dur-ms] [crot-on-ms] [crot-dur-ms] [pitch-name]
|
j@215
|
17 [midi-note-number] [chrom-pitch] [morph-pitch] [voice])
|
j@215
|
18 #.(clsql:locally-disable-sql-reader-syntax))
|
j@215
|
19
|
j@215
|
20 (defmethod get-composition ((identifier meredith-composition-identifier))
|
j@215
|
21 #.(clsql:locally-enable-sql-reader-syntax)
|
j@215
|
22 (let* ((composition-id (composition-id identifier))
|
j@215
|
23 (where-clause [= [composition-id] composition-id])
|
j@215
|
24 (description
|
j@215
|
25 (car (clsql:select [description] :from [|meredith-compositions|]
|
j@215
|
26 :where where-clause :flatp t :field-names nil)))
|
j@215
|
27 (db-events (apply #'clsql:select
|
j@215
|
28 (append *event-attributes*
|
j@215
|
29 (list :from [|meredith-events|]
|
j@215
|
30 :order-by '(([event-id] :asc))
|
j@215
|
31 :where where-clause))))
|
j@215
|
32 (events nil))
|
j@215
|
33 (dolist (e db-events)
|
j@215
|
34 (push (db-event->meredith-event e) events))
|
j@215
|
35 (let* ((composition
|
j@215
|
36 (make-meredith-composition :identifier identifier
|
j@215
|
37 :description description)))
|
j@215
|
38 (sequence:adjust-sequence composition (length events)
|
j@215
|
39 :initial-contents (nreverse events))
|
j@215
|
40 composition))
|
j@215
|
41 #.(clsql:locally-disable-sql-reader-syntax))
|
j@215
|
42
|
j@215
|
43 (defmethod copy-event (event)
|
j@215
|
44 (with-slots (identifier tatum-on tatum-dur tactus-on tactus-dur
|
j@215
|
45 (time amuse::time)
|
j@215
|
46 (interval amuse::interval) tatum-on-ms
|
j@215
|
47 tatum-dur-ms beat-on-ms beat-dur-ms
|
j@215
|
48 crot-on-ms crot-dur-ms pitch-name
|
j@215
|
49 (midi-note-number amuse::number)
|
j@215
|
50 (cp amuse::cp) (mp amuse::mp) voice) event
|
j@215
|
51 (make-meredith-event :identifier identifier
|
j@215
|
52 :tatum-on tatum-on
|
j@215
|
53 :tatum-dur tatum-dur
|
j@215
|
54 :tactus-on tactus-on
|
j@215
|
55 :tactus-dur tactus-dur
|
j@215
|
56 :time time
|
j@215
|
57 :interval interval
|
j@215
|
58 :tatum-on-ms tatum-on-ms
|
j@215
|
59 :tatum-dur-ms tatum-dur-ms
|
j@215
|
60 :beat-on-ms beat-on-ms
|
j@215
|
61 :beat-dur-ms beat-dur-ms
|
j@215
|
62 :crot-on-ms crot-on-ms
|
j@215
|
63 :crot-dur-ms crot-dur-ms
|
j@215
|
64 :pitch-name pitch-name
|
j@215
|
65 :number midi-note-number
|
j@215
|
66 :cp cp
|
j@215
|
67 :mp mp
|
j@215
|
68 :voice voice)))
|
j@215
|
69
|
j@215
|
70 (defmethod get-applicable-key-signatures ((event meredith-event)
|
j@215
|
71 (composition
|
j@215
|
72 meredith-composition))
|
j@215
|
73 nil)
|
j@215
|
74
|
j@215
|
75 (defmethod get-applicable-key-signatures ((event meredith-composition)
|
j@215
|
76 o)
|
j@215
|
77 nil)
|
j@215
|
78
|
j@215
|
79 (defmethod get-applicable-time-signatures ((event meredith-event)
|
j@215
|
80 (composition
|
j@215
|
81 meredith-composition))
|
j@215
|
82 (make-standard-time-signature-period 4 4 0 (duration composition)))
|
j@215
|
83
|
j@215
|
84 (defmethod time-signatures ((composition meredith-composition))
|
j@215
|
85 (list (make-standard-time-signature-period 4 4 0 (duration composition))))
|
j@215
|
86
|
j@215
|
87 (defmethod crotchet ((event meredith-composition))
|
j@215
|
88 (amuse:make-standard-period 1))
|
j@215
|
89
|
j@215
|
90 (defmethod crotchet ((event meredith-event))
|
j@215
|
91 (amuse:make-standard-period 1))
|
j@215
|
92
|
j@215
|
93 (defmethod tempi ((composition meredith-composition))
|
j@215
|
94 (list (make-standard-tempo-period 120 0 88)))
|