Mercurial > hg > amuse
comparison implementations/meredith/methods.lisp @ 215:4eceac78e7c6
add minimal backend for Dave Meredith's data
Ignore-this: 91608f727967a4c5709bd41634ab9ae2
darcs-hash:20090524193956-16a00-038e6f7cb235dea4e7efcc70c4d1a7bc7fd402a6.gz
committer: Jamie Forth <j.forth@gold.ac.uk>
author | j.forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 11:23:18 +0000 |
parents | |
children | 6f0881af3403 |
comparison
equal
deleted
inserted
replaced
214:545f80a73f03 | 215:4eceac78e7c6 |
---|---|
1 (cl:in-package #:amuse-meredith) | |
2 | |
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
4 ;;; Specialised constructors | |
5 (defmethod make-composition-identifier ((package (eql *package*)) | |
6 composition-id) | |
7 (make-meredith-composition-identifier composition-id)) | |
8 | |
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
10 ;;; Compositions | |
11 | |
12 (defvar *event-attributes* | |
13 #.(clsql:locally-enable-sql-reader-syntax) | |
14 (list [event-id] [tatum-on] [tatum-dur] [tactus-on] [tactus-dur] | |
15 [crot-on] [crot-dur] [tatum-on-ms] [tatum-dur-ms] [beat-on-ms] | |
16 [beat-dur-ms] [crot-on-ms] [crot-dur-ms] [pitch-name] | |
17 [midi-note-number] [chrom-pitch] [morph-pitch] [voice]) | |
18 #.(clsql:locally-disable-sql-reader-syntax)) | |
19 | |
20 (defmethod get-composition ((identifier meredith-composition-identifier)) | |
21 #.(clsql:locally-enable-sql-reader-syntax) | |
22 (let* ((composition-id (composition-id identifier)) | |
23 (where-clause [= [composition-id] composition-id]) | |
24 (description | |
25 (car (clsql:select [description] :from [|meredith-compositions|] | |
26 :where where-clause :flatp t :field-names nil))) | |
27 (db-events (apply #'clsql:select | |
28 (append *event-attributes* | |
29 (list :from [|meredith-events|] | |
30 :order-by '(([event-id] :asc)) | |
31 :where where-clause)))) | |
32 (events nil)) | |
33 (dolist (e db-events) | |
34 (push (db-event->meredith-event e) events)) | |
35 (let* ((composition | |
36 (make-meredith-composition :identifier identifier | |
37 :description description))) | |
38 (sequence:adjust-sequence composition (length events) | |
39 :initial-contents (nreverse events)) | |
40 composition)) | |
41 #.(clsql:locally-disable-sql-reader-syntax)) | |
42 | |
43 (defmethod copy-event (event) | |
44 (with-slots (identifier tatum-on tatum-dur tactus-on tactus-dur | |
45 (time amuse::time) | |
46 (interval amuse::interval) tatum-on-ms | |
47 tatum-dur-ms beat-on-ms beat-dur-ms | |
48 crot-on-ms crot-dur-ms pitch-name | |
49 (midi-note-number amuse::number) | |
50 (cp amuse::cp) (mp amuse::mp) voice) event | |
51 (make-meredith-event :identifier identifier | |
52 :tatum-on tatum-on | |
53 :tatum-dur tatum-dur | |
54 :tactus-on tactus-on | |
55 :tactus-dur tactus-dur | |
56 :time time | |
57 :interval interval | |
58 :tatum-on-ms tatum-on-ms | |
59 :tatum-dur-ms tatum-dur-ms | |
60 :beat-on-ms beat-on-ms | |
61 :beat-dur-ms beat-dur-ms | |
62 :crot-on-ms crot-on-ms | |
63 :crot-dur-ms crot-dur-ms | |
64 :pitch-name pitch-name | |
65 :number midi-note-number | |
66 :cp cp | |
67 :mp mp | |
68 :voice voice))) | |
69 | |
70 (defmethod get-applicable-key-signatures ((event meredith-event) | |
71 (composition | |
72 meredith-composition)) | |
73 nil) | |
74 | |
75 (defmethod get-applicable-key-signatures ((event meredith-composition) | |
76 o) | |
77 nil) | |
78 | |
79 (defmethod get-applicable-time-signatures ((event meredith-event) | |
80 (composition | |
81 meredith-composition)) | |
82 (make-standard-time-signature-period 4 4 0 (duration composition))) | |
83 | |
84 (defmethod time-signatures ((composition meredith-composition)) | |
85 (list (make-standard-time-signature-period 4 4 0 (duration composition)))) | |
86 | |
87 (defmethod crotchet ((event meredith-composition)) | |
88 (amuse:make-standard-period 1)) | |
89 | |
90 (defmethod crotchet ((event meredith-event)) | |
91 (amuse:make-standard-period 1)) | |
92 | |
93 (defmethod tempi ((composition meredith-composition)) | |
94 (list (make-standard-tempo-period 120 0 88))) |