comparison implementations/geerdes/constructors.lisp @ 217:d8f650e3796e

Rationalise base and geerdes classes, constructors and methods. Ignore-this: d9d4d88566a6d110844d91d4c70513cd Towards a more standardised interface. Some of these changes (generalised constructors and reader functions) are necessary for amuse-database-admin functionality and some other CHARM-like things. darcs-hash:20090716154406-16a00-8a9b4fb1fc1f5ba75af66a1bbd87e1bb68e02493.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 619194befdd4
children 7afb8cfdcdcf
comparison
equal deleted inserted replaced
216:e1842efb1dd4 217:d8f650e3796e
1 (cl:in-package #:amuse-geerdes) 1 (cl:in-package #:amuse-geerdes)
2
3 ;; Identifiers
4 ;; FIXME: use standard constructor names?
5 ;; FIXME: use standard composition-identifier?
6 (defun g-id (cat-id)
7 "Make a geerdes-identifier based on a catalogue id"
8 (make-instance 'geerdes-identifier-cat-id
9 :cat-id cat-id))
10
11 (defun g-id-file-id (file-id)
12 "Make a geerdes-identifier based on the file id. This is used as
13 the standard composition-id."
14 (make-instance 'geerdes-identifier-file-id
15 :file-id file-id))
16
17 (defun make-geerdes-event-identifier (event-id)
18 (make-instance 'geerdes-event-identifier
19 :event-id event-id))
20
21 ;; Events
2 22
3 (defgeneric %initialise-notes (composition)) 23 (defgeneric %initialise-notes (composition))
4 (defmethod %initialise-notes ((composition geerdes-composition)) 24 (defmethod %initialise-notes ((composition geerdes-composition))
5 (let ((notes) (l 0) (last-time 0) (monody-notes) 25 (let ((notes) (l 0) (last-time 0) (monody-notes)
6 (monody (make-instance 'geerdes-monody :file-id (file-id composition))) 26 (monody (make-instance 'geerdes-monody :file-id (file-id composition)))
106 126
107 (defun pitched-row-p (event-row) 127 (defun pitched-row-p (event-row)
108 (and (not (= (%fast-channel event-row) 10)) 128 (and (not (= (%fast-channel event-row) 10))
109 (< (%fast-patch event-row) 112))) 129 (< (%fast-patch event-row) 112)))
110 130
111 (defun make-geerdes-pitched-event (pitch-number velocity patch 131 (defun make-geerdes-pitched-event (pitch-number velocity patch channel
112 channel track onset duration id) 132 track onset duration event-id)
113 (make-instance 'geerdes-pitched-event 133 (make-instance 'geerdes-pitched-event
114 :number pitch-number 134 :number pitch-number
115 :velocity velocity 135 :velocity velocity
116 :patch patch 136 :patch patch
117 :channel channel 137 :channel channel
118 :track track 138 :track track
119 :time onset 139 :time onset
120 :interval duration 140 :interval duration
121 :id id)) 141 :identifier (make-geerdes-event-identifier
142 event-id)))
122 143
123 (defun make-geerdes-percussive-event (pitch-number velocity patch 144 (defun make-geerdes-percussive-event (pitch-number velocity patch
124 channel track onset duration id) 145 channel track onset duration
146 event-id)
125 (make-instance 'geerdes-percussive-event 147 (make-instance 'geerdes-percussive-event
126 :sound pitch-number 148 :sound pitch-number
127 :velocity velocity 149 :velocity velocity
128 :patch patch 150 :patch patch
129 :channel channel 151 :channel channel
130 :track track 152 :track track
131 :time onset 153 :time onset
132 :interval duration 154 :interval duration
133 :id id)) 155 :identifier (make-geerdes-event-identifier
156 event-id)))
134 157
135 (defmethod copy-event ((event geerdes-pitched-event)) 158 (defmethod copy-event ((event geerdes-pitched-event))
136 (with-slots ((channel amuse-midi::channel) 159 (with-slots ((channel amuse-midi::channel)
137 (track amuse-midi::track) 160 (track amuse-midi::track)
138 (number amuse::number) 161 (number amuse::number)
139 (time amuse::time) 162 (time amuse::time)
140 (interval amuse::interval) 163 (interval amuse::interval)
141 (velocity amuse-midi::velocity) 164 (velocity amuse-midi::velocity)
142 (patch amuse-midi::patch) id) 165 (patch amuse-midi::patch)
166 identifier)
143 event 167 event
144 (make-instance 'geerdes-pitched-event 168 (make-instance 'geerdes-pitched-event
145 :channel channel 169 :channel channel
146 :track track 170 :track track
147 :number number 171 :number number
148 :time time 172 :time time
149 :interval interval 173 :interval interval
150 :velocity velocity 174 :velocity velocity
151 :patch patch 175 :patch patch
152 :id id))) 176 :identifier identifier)))
177
153 (defmethod copy-event ((event geerdes-percussive-event)) 178 (defmethod copy-event ((event geerdes-percussive-event))
154 (with-slots ((channel amuse-midi::channel) 179 (with-slots ((channel amuse-midi::channel)
155 (track amuse-midi::track) 180 (track amuse-midi::track)
156 (time amuse::time) 181 (time amuse::time)
157 (interval amuse::interval) 182 (interval amuse::interval)
158 (velocity amuse-midi::velocity) 183 (velocity amuse-midi::velocity)
159 (patch amuse-midi::patch) 184 (patch amuse-midi::patch)
160 (sound amuse-midi::sound) id) 185 (sound amuse-midi::sound)
186 identifier)
161 event 187 event
162 (make-instance 'geerdes-percussive-event 188 (make-instance 'geerdes-percussive-event
163 :channel channel 189 :channel channel
164 :track track 190 :track track
165 :time time 191 :time time
166 :interval interval 192 :interval interval
167 :velocity velocity 193 :velocity velocity
168 :patch patch 194 :patch patch
169 :sound sound 195 :sound sound
170 :id id))) 196 :identifier identifier)))
171 197
172 ;; We want any function that generates a sequence from a geerdes 198 ;; We want any function that generates a sequence from a geerdes
173 ;; composition to preserve all slot values: 199 ;; composition to preserve all slot values:
174 #+nil 200 #+nil
175 (defmethod sequence:make-sequence-like :around ((o geerdes-composition) 201 (defmethod sequence:make-sequence-like :around ((o geerdes-composition)