diff implementations/meredith/constructors.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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/implementations/meredith/constructors.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -0,0 +1,43 @@
+(cl:in-package #:amuse-meredith)
+
+(defun make-meredith-composition-identifier (composition-id)
+  (make-instance 'meredith-composition-identifier
+		 :composition-id composition-id))
+
+(defun make-meredith-composition (&key events time interval
+				  identifier description)
+  (make-instance 'meredith-composition
+		 :%data events
+		 :time time
+		 :interval interval
+		 :identifier identifier
+		 :description description))
+
+(defun make-meredith-event (&rest args)
+  (apply #'make-instance 'meredith-event args))
+
+(defun db-event->meredith-event (db-event)
+  (destructuring-bind (event-id tatum-on tatum-dur tactus-on
+				tactus-dur crot-on crot-dur
+				tatum-on-ms tatum-dur-ms beat-on-ms
+				beat-dur-ms crot-on-ms crot-dur-ms
+				pitch-name midi-note-number cpitch
+				mpitch voice) db-event
+    (make-meredith-event :identifier event-id
+			 :tatum-on tatum-on
+			 :tatum-dur tatum-dur
+			 :tactus-on tactus-on
+			 :tactus-dur tactus-dur
+			 :time crot-on	; define crotchet as standard time
+			 :interval crot-dur
+			 :tatum-on-ms tatum-on-ms
+			 :tatum-dur-ms tatum-dur-ms
+			 :beat-on-ms beat-on-ms
+			 :beat-dur-ms beat-dur-ms
+			 :crot-on-ms crot-on-ms
+			 :crot-dur-ms crot-dur-ms
+			 :pitch-name pitch-name
+			 :number midi-note-number
+			 :cp cpitch
+			 :mp mpitch
+			 :voice voice)))