Mercurial > hg > amuse
diff 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 |
line wrap: on
line diff
--- a/implementations/geerdes/constructors.lisp Thu Feb 24 11:23:18 2011 +0000 +++ b/implementations/geerdes/constructors.lisp Thu Feb 24 11:23:18 2011 +0000 @@ -1,5 +1,25 @@ (cl:in-package #:amuse-geerdes) +;; Identifiers +;; FIXME: use standard constructor names? +;; FIXME: use standard composition-identifier? +(defun g-id (cat-id) + "Make a geerdes-identifier based on a catalogue id" + (make-instance 'geerdes-identifier-cat-id + :cat-id cat-id)) + +(defun g-id-file-id (file-id) + "Make a geerdes-identifier based on the file id. This is used as +the standard composition-id." + (make-instance 'geerdes-identifier-file-id + :file-id file-id)) + +(defun make-geerdes-event-identifier (event-id) + (make-instance 'geerdes-event-identifier + :event-id event-id)) + +;; Events + (defgeneric %initialise-notes (composition)) (defmethod %initialise-notes ((composition geerdes-composition)) (let ((notes) (l 0) (last-time 0) (monody-notes) @@ -108,8 +128,8 @@ (and (not (= (%fast-channel event-row) 10)) (< (%fast-patch event-row) 112))) -(defun make-geerdes-pitched-event (pitch-number velocity patch - channel track onset duration id) +(defun make-geerdes-pitched-event (pitch-number velocity patch channel + track onset duration event-id) (make-instance 'geerdes-pitched-event :number pitch-number :velocity velocity @@ -118,10 +138,12 @@ :track track :time onset :interval duration - :id id)) + :identifier (make-geerdes-event-identifier + event-id))) (defun make-geerdes-percussive-event (pitch-number velocity patch - channel track onset duration id) + channel track onset duration + event-id) (make-instance 'geerdes-percussive-event :sound pitch-number :velocity velocity @@ -130,7 +152,8 @@ :track track :time onset :interval duration - :id id)) + :identifier (make-geerdes-event-identifier + event-id))) (defmethod copy-event ((event geerdes-pitched-event)) (with-slots ((channel amuse-midi::channel) @@ -139,7 +162,8 @@ (time amuse::time) (interval amuse::interval) (velocity amuse-midi::velocity) - (patch amuse-midi::patch) id) + (patch amuse-midi::patch) + identifier) event (make-instance 'geerdes-pitched-event :channel channel @@ -149,7 +173,8 @@ :interval interval :velocity velocity :patch patch - :id id))) + :identifier identifier))) + (defmethod copy-event ((event geerdes-percussive-event)) (with-slots ((channel amuse-midi::channel) (track amuse-midi::track) @@ -157,7 +182,8 @@ (interval amuse::interval) (velocity amuse-midi::velocity) (patch amuse-midi::patch) - (sound amuse-midi::sound) id) + (sound amuse-midi::sound) + identifier) event (make-instance 'geerdes-percussive-event :channel channel @@ -167,7 +193,7 @@ :velocity velocity :patch patch :sound sound - :id id))) + :identifier identifier))) ;; We want any function that generates a sequence from a geerdes ;; composition to preserve all slot values: