annotate implementations/meredith/methods.lisp @ 330:2fbff655ba47 tip

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