annotate implementations/meredith/methods.lisp @ 296:68aadc4eb96d

add chromatic-pitch reader method Ignore-this: 1aba35b7d196e0994a817609337746e1 darcs-hash:20090828145217-16a00-312e63170f50f0bf2834b8959a72e5c857cba9b8.gz
author j.forth <j.forth@gold.ac.uk>
date Fri, 28 Aug 2009 15:52:17 +0100
parents d22c67dac97d
children 6f0881af3403
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@286 25 (car (clsql:select [description] :from [|meredith-compositions|]
j@286 26 :where where-clause :flatp t :field-names nil)))
j@286 27 (db-events (apply #'clsql:select
j@286 28 (append *event-attributes*
j@286 29 (list :from [|meredith-events|]
j@286 30 :order-by '(([event-id] :asc))
j@286 31 :where where-clause))))
j@286 32 (events nil))
j@286 33 (dolist (e db-events)
j@286 34 (push (db-event->meredith-event e) events))
j@286 35 (let* ((composition
j@286 36 (make-meredith-composition :identifier identifier
j@286 37 :description description)))
j@286 38 (sequence:adjust-sequence composition (length events)
j@286 39 :initial-contents (nreverse events))
j@286 40 composition))
j@286 41 #.(clsql:locally-disable-sql-reader-syntax))
j@286 42
j@286 43 (defmethod copy-event (event)
j@286 44 (with-slots (identifier tatum-on tatum-dur tactus-on tactus-dur
j@286 45 (time amuse::time)
j@286 46 (interval amuse::interval) tatum-on-ms
j@286 47 tatum-dur-ms beat-on-ms beat-dur-ms
j@286 48 crot-on-ms crot-dur-ms pitch-name
j@286 49 (midi-note-number amuse::number)
j@286 50 (cp amuse::cp) (mp amuse::mp) voice) event
j@286 51 (make-meredith-event :identifier identifier
j@286 52 :tatum-on tatum-on
j@286 53 :tatum-dur tatum-dur
j@286 54 :tactus-on tactus-on
j@286 55 :tactus-dur tactus-dur
j@286 56 :time time
j@286 57 :interval interval
j@286 58 :tatum-on-ms tatum-on-ms
j@286 59 :tatum-dur-ms tatum-dur-ms
j@286 60 :beat-on-ms beat-on-ms
j@286 61 :beat-dur-ms beat-dur-ms
j@286 62 :crot-on-ms crot-on-ms
j@286 63 :crot-dur-ms crot-dur-ms
j@286 64 :pitch-name pitch-name
j@286 65 :number midi-note-number
j@286 66 :cp cp
j@286 67 :mp mp
j@286 68 :voice voice)))
j@286 69
j@286 70 (defmethod get-applicable-key-signatures ((event meredith-event)
j@286 71 (composition
j@286 72 meredith-composition))
j@286 73 nil)
j@286 74
j@286 75 (defmethod get-applicable-key-signatures ((event meredith-composition)
j@286 76 o)
j@286 77 nil)
j@286 78
j@286 79 (defmethod get-applicable-time-signatures ((event meredith-event)
j@286 80 (composition
j@286 81 meredith-composition))
j@286 82 (make-standard-time-signature-period 4 4 0 (duration composition)))
j@286 83
j@286 84 (defmethod time-signatures ((composition meredith-composition))
j@286 85 (list (make-standard-time-signature-period 4 4 0 (duration composition))))
j@286 86
j@286 87 (defmethod crotchet ((event meredith-composition))
j@286 88 (amuse:make-standard-period 1))
j@286 89
j@286 90 (defmethod crotchet ((event meredith-event))
j@286 91 (amuse:make-standard-period 1))
j@286 92
j@286 93 (defmethod tempi ((composition meredith-composition))
j@286 94 (list (make-standard-tempo-period 120 0 88)))