annotate implementations/meredith/methods.lisp @ 299:f5734df598f4

add composition slot to event (meredith) Ignore-this: d6b133f7d17684bf3f7c1ccde28c7d8a darcs-hash:20090828164631-16a00-1a25e46b8142401466f4a6ec7159a10d8e31de40.gz
author j.forth <j.forth@gold.ac.uk>
date Fri, 28 Aug 2009 17:46:31 +0100
parents d22c67dac97d
children 7412629f5c78
rev   line source
j@286 1 (cl:in-package #:amuse-meredith)
j@286 2
j@286 3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@286 4 ;;; Specialised constructors
j@286 5 (defmethod make-composition-identifier ((package (eql *package*))
j@286 6 composition-id)
j@286 7 (make-meredith-composition-identifier composition-id))
j@286 8
j@286 9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@286 10 ;;; Compositions
j@286 11
j@286 12 (defvar *event-attributes*
j@286 13 #.(clsql:locally-enable-sql-reader-syntax)
j@286 14 (list [event-id] [tatum-on] [tatum-dur] [tactus-on] [tactus-dur]
j@286 15 [crot-on] [crot-dur] [tatum-on-ms] [tatum-dur-ms] [beat-on-ms]
j@286 16 [beat-dur-ms] [crot-on-ms] [crot-dur-ms] [pitch-name]
j@286 17 [midi-note-number] [chrom-pitch] [morph-pitch] [voice])
j@286 18 #.(clsql:locally-disable-sql-reader-syntax))
j@286 19
j@286 20 (defmethod get-composition ((identifier meredith-composition-identifier))
j@286 21 #.(clsql:locally-enable-sql-reader-syntax)
j@286 22 (let* ((composition-id (composition-id identifier))
j@286 23 (where-clause [= [composition-id] composition-id])
j@286 24 (description
j@299 25 (car (clsql:select [description]
j@299 26 :from [|meredith-compositions|]
j@299 27 :where where-clause
j@299 28 :flatp t
j@299 29 :field-names nil
j@299 30 :database *amuse-database*)))
j@299 31 (composition (make-meredith-composition
j@299 32 :identifier identifier
j@299 33 :description description))
j@286 34 (db-events (apply #'clsql:select
j@286 35 (append *event-attributes*
j@286 36 (list :from [|meredith-events|]
j@286 37 :order-by '(([event-id] :asc))
j@299 38 :where where-clause
j@299 39 :database *amuse-database*))))
j@299 40 (events (loop for e in db-events
j@299 41 collect (db-event->meredith-event e composition))))
j@299 42 (sequence:adjust-sequence composition (length events)
j@299 43 :initial-contents events))
j@286 44 #.(clsql:locally-disable-sql-reader-syntax))
j@286 45
j@286 46 (defmethod copy-event (event)
j@286 47 (with-slots (identifier tatum-on tatum-dur tactus-on tactus-dur
j@286 48 (time amuse::time)
j@286 49 (interval amuse::interval) tatum-on-ms
j@286 50 tatum-dur-ms beat-on-ms beat-dur-ms
j@286 51 crot-on-ms crot-dur-ms pitch-name
j@286 52 (midi-note-number amuse::number)
j@286 53 (cp amuse::cp) (mp amuse::mp) voice) event
j@286 54 (make-meredith-event :identifier identifier
j@286 55 :tatum-on tatum-on
j@286 56 :tatum-dur tatum-dur
j@286 57 :tactus-on tactus-on
j@286 58 :tactus-dur tactus-dur
j@286 59 :time time
j@286 60 :interval interval
j@286 61 :tatum-on-ms tatum-on-ms
j@286 62 :tatum-dur-ms tatum-dur-ms
j@286 63 :beat-on-ms beat-on-ms
j@286 64 :beat-dur-ms beat-dur-ms
j@286 65 :crot-on-ms crot-on-ms
j@286 66 :crot-dur-ms crot-dur-ms
j@286 67 :pitch-name pitch-name
j@286 68 :number midi-note-number
j@286 69 :cp cp
j@286 70 :mp mp
j@286 71 :voice voice)))
j@286 72
j@286 73 (defmethod get-applicable-key-signatures ((event meredith-event)
j@286 74 (composition
j@286 75 meredith-composition))
j@286 76 nil)
j@286 77
j@286 78 (defmethod get-applicable-key-signatures ((event meredith-composition)
j@286 79 o)
j@286 80 nil)
j@286 81
j@286 82 (defmethod get-applicable-time-signatures ((event meredith-event)
j@286 83 (composition
j@286 84 meredith-composition))
j@286 85 (make-standard-time-signature-period 4 4 0 (duration composition)))
j@286 86
j@286 87 (defmethod time-signatures ((composition meredith-composition))
j@286 88 (list (make-standard-time-signature-period 4 4 0 (duration composition))))
j@286 89
j@286 90 (defmethod crotchet ((event meredith-composition))
j@286 91 (amuse:make-standard-period 1))
j@286 92
j@286 93 (defmethod crotchet ((event meredith-event))
j@286 94 (amuse:make-standard-period 1))
j@286 95
j@286 96 (defmethod tempi ((composition meredith-composition))
j@286 97 (list (make-standard-tempo-period 120 0 88)))