Mercurial > hg > amuse
comparison implementations/geerdes/methods.lisp @ 211:e2839225f6fb
integrate db-admin into geerdes
Ignore-this: 442285f4febbcd5d390a49d8c8b69e00
darcs-hash:20090522211215-16a00-0e6571178e720d2cf648e09486ec2bb160950355.gz
committer: Jamie Forth <j.forth@gold.ac.uk>
author | j.forth <j.forth@gold.ac.uk> |
---|---|
date | Thu, 24 Feb 2011 11:23:17 +0000 |
parents | 4cb3ec07831f |
children | 619194befdd4 |
comparison
equal
deleted
inserted
replaced
210:be3d63b78054 | 211:e2839225f6fb |
---|---|
34 (defmethod (setf file-id) (value (object geerdes-composition)) | 34 (defmethod (setf file-id) (value (object geerdes-composition)) |
35 (setf (%db-file-id object) value)) | 35 (setf (%db-file-id object) value)) |
36 (defmethod (setf file-id) (value (object geerdes-identifier-file-id)) | 36 (defmethod (setf file-id) (value (object geerdes-identifier-file-id)) |
37 (setf (slot-value object 'file-id) value)) | 37 (setf (slot-value object 'file-id) value)) |
38 | 38 |
39 ;; Specialised constructors | |
40 | |
41 (defmethod make-composition-identifier ((package (eql *package*)) | |
42 composition-id) | |
43 (g-id-file-id composition-id)) | |
44 | |
39 ;; Composition | 45 ;; Composition |
40 | 46 |
41 (defmethod get-composition ((identifier geerdes-identifier)) | 47 (defmethod get-composition ((identifier geerdes-identifier)) |
42 (let* ((composition (get-geerdes-composition identifier))) | 48 (let* ((composition (get-geerdes-composition identifier))) |
43 (%initialise-notes composition) | 49 (%initialise-notes composition) |
49 (let* ((cat-id (cat-id identifier)) | 55 (let* ((cat-id (cat-id identifier)) |
50 (file-info (car (clsql:select [id] [timebase] | 56 (file-info (car (clsql:select [id] [timebase] |
51 :from [midi_file] | 57 :from [midi_file] |
52 :where [= [cat_id] cat-id] | 58 :where [= [cat_id] cat-id] |
53 :flatp t | 59 :flatp t |
54 :result-types :auto))) | 60 :result-types :auto |
61 :database *amuse-database*))) | |
55 (timebase (second file-info)) | 62 (timebase (second file-info)) |
56 (file-id (first file-info)) | 63 (file-id (first file-info)) |
57 (composition (make-instance 'geerdes-composition | 64 (composition (make-instance 'geerdes-composition |
58 :id identifier | 65 :id identifier |
59 :file-id file-id | 66 :file-id file-id |
61 :midi-timebase timebase))) | 68 :midi-timebase timebase))) |
62 (setf (%midi-events composition) (get-db-events file-id) | 69 (setf (%midi-events composition) (get-db-events file-id) |
63 (%midi-constituents composition) (get-db-constituents file-id)) | 70 (%midi-constituents composition) (get-db-constituents file-id)) |
64 #.(clsql:restore-sql-reader-syntax-state) | 71 #.(clsql:restore-sql-reader-syntax-state) |
65 composition)) | 72 composition)) |
73 | |
66 (defmethod get-geerdes-composition ((identifier geerdes-identifier-file-id)) | 74 (defmethod get-geerdes-composition ((identifier geerdes-identifier-file-id)) |
67 #.(clsql:locally-enable-sql-reader-syntax) | 75 #.(clsql:locally-enable-sql-reader-syntax) |
68 (let* ((file-id (file-id identifier)) | 76 (let* ((file-id (file-id identifier)) |
69 (file-info (car (clsql:select [cat_id] [timebase] | 77 (file-info (car (clsql:select [cat_id] [timebase] |
70 :from [midi_file] | 78 :from [midi_file] |
71 :where [= [id] file-id] | 79 :where [= [id] file-id] |
72 :flatp t | 80 :flatp t |
73 :result-types :auto))) | 81 :result-types :auto |
82 :database *amuse-database*))) | |
74 (timebase (second file-info)) | 83 (timebase (second file-info)) |
75 (cat-id (first file-info)) | 84 (cat-id (first file-info)) |
76 (composition (make-instance 'geerdes-composition | 85 (composition (make-instance 'geerdes-composition |
77 :id identifier | 86 :id identifier |
78 :cat-id cat-id | 87 :cat-id cat-id |
87 (clsql:query | 96 (clsql:query |
88 (concatenate 'string " | 97 (concatenate 'string " |
89 SELECT track, channel, start, duration, patch, pitch, velocity, id, event_id, mel_duration | 98 SELECT track, channel, start, duration, patch, pitch, velocity, id, event_id, mel_duration |
90 FROM midi_event LEFT JOIN derived_midi_monody ON (id=event_id) | 99 FROM midi_event LEFT JOIN derived_midi_monody ON (id=event_id) |
91 WHERE file_id=" (princ-to-string file-id) | 100 WHERE file_id=" (princ-to-string file-id) |
92 " ORDER BY start"))) | 101 " ORDER BY start") |
102 :database *amuse-database*)) | |
103 | |
93 (defun get-db-constituents (file-id) | 104 (defun get-db-constituents (file-id) |
94 (clsql:query (concatenate 'string " | 105 (clsql:query (concatenate 'string " |
95 SELECT track, channel, start, duration, | 106 SELECT track, channel, start, duration, |
96 param.num, param.value, pb.value, tp.value, ts.num, ts.denom | 107 param.num, param.value, pb.value, tp.value, ts.num, ts.denom |
97 FROM midi_constituent c | 108 FROM midi_constituent c |
98 LEFT JOIN midi_pb pb ON (id=pb.constituent_id) | 109 LEFT JOIN midi_pb pb ON (id=pb.constituent_id) |
99 LEFT JOIN midi_tempo tp ON (id=tp.constituent_id) | 110 LEFT JOIN midi_tempo tp ON (id=tp.constituent_id) |
100 LEFT JOIN midi_timesig ts ON (id=ts.constituent_id) | 111 LEFT JOIN midi_timesig ts ON (id=ts.constituent_id) |
101 LEFT JOIN midi_param param ON (id=param.constituent_id) | 112 LEFT JOIN midi_param param ON (id=param.constituent_id) |
102 WHERE c.file_id=" (princ-to-string file-id) | 113 WHERE c.file_id=" (princ-to-string file-id) |
103 " ORDER BY start"))) | 114 " ORDER BY start") |
115 :database *amuse-database*)) | |
104 | 116 |
105 (defmethod monody ((composition geerdes-composition)) | 117 (defmethod monody ((composition geerdes-composition)) |
106 (unless (amuse-geerdes::%monody composition) | 118 (unless (amuse-geerdes::%monody composition) |
107 (setf (amuse-geerdes::%monody composition) | 119 (setf (amuse-geerdes::%monody composition) |
108 (get-monody composition))) | 120 (get-monody composition))) |
147 (defmethod lead-vocalp ((event geerdes-pitched-event)) | 159 (defmethod lead-vocalp ((event geerdes-pitched-event)) |
148 (= (midi-channel event) 4)) | 160 (= (midi-channel event) 4)) |
149 | 161 |
150 (defmethod crotchet ((object geerdes-object)) | 162 (defmethod crotchet ((object geerdes-object)) |
151 (make-standard-period 1)) | 163 (make-standard-period 1)) |
152 |