annotate base/classes.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 328114b61465
children ead979ad3b28
rev   line source
j@190 1 (cl:in-package #:amuse)
j@190 2
j@190 3 ;; top-level amuse object
j@190 4
j@190 5 (defclass amuse-object () ())
j@190 6
j@190 7 ;; types of information-specifiers
j@190 8
j@190 9 (defclass identifier (amuse-object) ()
j@190 10 (:documentation "DEPRECATED: Base class to allow specification of
j@217 11 composition to get. Must be subclassed.")) ; FIXME: Why deprecated?
j@190 12
j@190 13 (defclass constituent-identifier (identifier) ()
j@217 14 (:documentation "Base class to allow specification of
j@217 15 constituents"))
j@217 16
j@190 17 (defclass composition-identifier (constituent-identifier) ()
j@217 18 (:documentation "Base class to allow specification of
j@217 19 compositions constituents"))
j@217 20
j@217 21 (defclass event-identifier (identifier) ()
j@217 22 (:documentation "Base class to allow specification of events."))
j@190 23
j@190 24 (defclass moment (amuse-object) ()
j@190 25 (:documentation "Object indicating a point in time"))
j@190 26 (defclass period (amuse-object) ()
j@190 27 (:documentation "Object indicating a region of time"))
j@190 28 (defclass anchored-period (moment period) ()
j@190 29 (:documentation "Object indicating a region of time starting at
j@190 30 a specific point in time"))
j@190 31 (defclass pitch (amuse-object) ()
j@190 32 (:documentation "Object indicating some sort of pitch"))
j@190 33 (defclass pitch-interval (amuse-object) ()
j@190 34 (:documentation "Object indicating a distance in pitch space"))
j@190 35
j@190 36 ;; time-related classes
j@190 37
j@190 38 (defclass standard-moment (moment)
j@190 39 ((time :accessor %moment-time :initarg :time))
j@190 40 (:documentation "A moment that has time represented on a
j@190 41 continuous, progressive number line"))
j@190 42
j@190 43 (defclass standard-period (period)
j@190 44 ((interval :accessor %period-interval :initarg :interval))
j@190 45 (:documentation "A period that places time intervals
j@190 46 on a progressive number-line"))
j@190 47
j@190 48 (defclass standard-anchored-period (standard-period standard-moment anchored-period) ()
j@190 49 (:documentation "Number-line-based anchored period"))
j@190 50
j@190 51 ;; pitch-related classes
j@190 52
j@190 53 (defclass frequency-pitch (pitch) ())
j@190 54
j@190 55 (defclass chromatic-pitch (pitch)
j@190 56 ((number :accessor %chromatic-pitch-number :initarg :number))
j@190 57 (:documentation "A pitch represented as a number, with
j@190 58 chromatic pitches having distinct values."))
j@190 59 (defclass diatonic-pitch (pitch)
j@190 60 ((cp :initarg :cp :accessor %p-pc :reader diatonic-pitch-cp)
j@190 61 (mp :initarg :mp :accessor %p-pm :reader diatonic-pitch-mp))
j@190 62 (:documentation "A diatonic pitch, represented using MIPS: cp is an
j@190 63 integer representing chromatic pitch (An0 = 0, middle C = 39); mp is
j@190 64 an integer representing the morphetic pitch (An0 = 0, middle C =
j@190 65 23)."))
j@190 66
j@190 67 (defclass chromatic-pitch-interval (pitch-interval)
j@190 68 ((span :accessor %chromatic-pitch-interval-span :initarg :span))
j@190 69 (:documentation "An interval represented as a number, recording
j@190 70 the number of ascending chromatic pitches between two pitches."))
j@190 71
j@190 72 (defclass diatonic-pitch-interval (pitch-interval)
j@190 73 ((span :accessor %diatonic-pitch-interval-span :initarg :span :reader span))
j@190 74 (:documentation "How is this inplemented?"))
j@190 75
j@190 76 ;; events
j@190 77
j@190 78 (defclass event (anchored-period) ()
j@190 79 (:documentation "Notelike object"))
j@190 80 (defclass pitched-event (event pitch) ()
j@190 81 (:documentation "Event with pitch information"))
j@190 82 (defclass standard-pitched-event (pitched-event
j@190 83 standard-anchored-period) ()
j@190 84 (:documentation "Event with pitch information"))
j@190 85 (defclass chromatic-pitched-event (pitched-event chromatic-pitch) ()
j@190 86 (:documentation "Event with chromatic pitch information"))
j@190 87 (defclass standard-chromatic-pitched-event (chromatic-pitched-event
j@190 88 standard-anchored-period) ()
j@190 89 (:documentation "Event with chromatic pitch information and
j@190 90 standard-period"))
j@213 91 (defclass diatonic-pitched-event (pitched-event diatonic-pitch) ()
j@213 92 (:documentation "Event with diatonic pitch information"))
j@213 93 (defclass standard-diatonic-pitched-event (diatonic-pitched-event
j@213 94 standard-anchored-period) ()
j@213 95 (:documentation "Event with diatonic pitch information and
j@213 96 standard-period"))
j@190 97 (defclass percussive-event (event) ()
j@190 98 (:documentation "Unpitched percussion Event. There's an issue
j@190 99 with this name - is there a reason why this is unpitched
j@190 100 necessarily, or why I'm not counting piano, etc in this? Perhaps
j@190 101 what I mean is that it should be renamed unpitched-event?
j@190 102 Actually, is this necessary? Isn't this just an event?"))
j@190 103 (defclass standard-percussive-event (event standard-anchored-period) ()
j@190 104 (:documentation "Unpitched percussion Event. There's an issue
j@190 105 with this name - is there a reason why this is unpitched
j@190 106 necessarily, or why I'm not counting piano, etc in this? Perhaps
j@190 107 what I mean is that it should be renamed unpitched-event?
j@190 108 Actually, is this necessary? Isn't this just an event?
j@190 109 Timbral/instrumental information will be generalised later but is
j@190 110 less agreed-on than pitch."))
j@190 111
j@190 112 ;;; Range-based `constituents'
j@190 113 ;; Whilst these are all constituents in the CHARM sense, their
j@190 114 ;; properties apply to a timed range rather than to a set of
j@190 115 ;; events. As such, they can be regarded as anchored-periods with
j@190 116 ;; properties.
j@190 117
j@190 118 (defclass time-signature (amuse-object) ()
j@190 119 (:documentation "Abstract class for time signature"))
j@190 120
j@190 121 (defclass time-signature-period (time-signature anchored-period) ()
j@190 122 (:documentation "Abstract class for time signatures in time"))
j@190 123
j@190 124 (defclass standard-time-signature (time-signature)
j@190 125 ((numerator :accessor %basic-time-signature-numerator
j@190 126 :initarg :numerator)
j@190 127 (denominator :accessor %basic-time-signature-denominator
j@190 128 :initarg :denominator))
j@190 129 (:documentation "Class with slots for numerator and
j@190 130 denominator. Can only deal with numeric signatures."))
j@190 131
j@190 132 (defclass standard-time-signature-period (standard-time-signature
j@190 133 time-signature-period
j@190 134 standard-anchored-period)
j@190 135 ()
j@190 136 (:documentation "STANDARD-TIME-SIGNATURE on a time number line"))
j@190 137
j@190 138 (defclass key-signature (amuse-object) ()
j@190 139 (:documentation "Base class for key signature"))
j@190 140
j@190 141 (defclass key-signature-period (key-signature anchored-period) ()
j@190 142 (:documentation "Abstract class for time signatures in time"))
j@190 143
j@190 144 (defclass standard-key-signature (key-signature)
j@190 145 ((sharp-count :accessor %basic-key-signature-sharp-count
j@190 146 :initarg :sharp-count))
j@190 147 (:documentation "Simple class - Only has line-of-fifths
j@190 148 distance from c, so custom signatures won't work"))
j@190 149
j@190 150 (defclass standard-key-signature-period (standard-key-signature
j@190 151 key-signature-period
j@190 152 standard-anchored-period)
j@190 153 ()
j@190 154 (:documentation "STANDARD-KEY-SIGNATURE on a time number line"))
j@190 155
j@190 156 (defclass midi-key-signature (standard-key-signature)
j@190 157 ((mode :accessor %midi-key-signature-mode
j@190 158 :initarg :mode))
j@190 159 (:documentation "MIDI-based flavour of basic key signature,
j@190 160 adding a slot for mode: 0 = major key; 1 = minor key"))
j@190 161
j@190 162 (defclass midi-key-signature-period (standard-key-signature-period
j@190 163 midi-key-signature)
j@190 164 ()
j@190 165 (:documentation "MIDI-KEY-SIGNATURE on a time number line"))
j@190 166
j@190 167 (defclass tempo (amuse-object) ()
j@190 168 (:documentation "Abstract class for tempo"))
j@190 169 (defclass tempo-period (tempo anchored-period) ()
j@190 170 (:documentation "Abstract class for tempo associated with a
j@190 171 time period"))
j@190 172 (defclass standard-tempo (tempo)
j@190 173 ((bpm :accessor %tempo-bpm
j@190 174 :initarg :bpm))
j@190 175 (:documentation "Rather literal reading of absolute tempo.
j@190 176 accel and rit in symbolic encoding will need other structures,
j@190 177 as will textual tempo markings."))
j@190 178 (defclass standard-tempo-period (standard-tempo
j@190 179 tempo-period
j@190 180 standard-anchored-period)
j@190 181 ()
j@190 182 (:documentation "Tempo associated with a standard-anchored-period"))
j@190 183
j@190 184 ;; collections of more than one event
j@190 185
j@190 186 (defclass constituent (anchored-period) ()
j@190 187 (:documentation "Base class for constituents"))
j@190 188 (defclass standard-constituent (constituent standard-anchored-period) ()
j@190 189 (:documentation "Base class for constituents using standard
j@190 190 time representation"))
j@190 191
j@190 192 (defclass time-ordered-constituent (constituent list-slot-sequence)
j@190 193 ;; this won't work if lisp implementation doesn't support extensible
j@190 194 ;; sequences.
j@190 195 ())
j@190 196 (defclass standard-time-ordered-constituent (time-ordered-constituent
j@190 197 standard-constituent
j@190 198 list-slot-sequence)
j@190 199 ;; this won't work if lisp implementation doesn't support extensible
j@190 200 ;; sequences.
j@190 201 ())
j@190 202
j@190 203
j@190 204 (defclass composition (time-ordered-constituent) ()
j@190 205 (:documentation "Base class for compositions"))
j@190 206
j@190 207 (defclass standard-composition (composition
j@190 208 standard-time-ordered-constituent) ()
j@190 209 (:documentation "Base class for compositions using standard
j@190 210 time representation"))
j@190 211 (defclass monody (composition) ()
j@190 212 (:documentation "Class for indicating suitability for analysis
j@190 213 requiring a monody"))
j@190 214 (defclass standard-monody (monody standard-composition) ())
j@190 215
j@190 216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
j@190 217 ;;
j@190 218 ;; Experimental:
j@190 219 ;;
j@190 220
j@190 221 (defclass clef (amuse-object) ()
j@190 222 (:documentation "Abstract class for clef implementations"))
j@190 223
j@190 224 (defclass clef-period (clef anchored-period) ()
j@190 225 (:documentation "Abstract class for clef implementations in time"))
j@190 226
j@190 227 (defclass standard-clef (clef)
j@190 228 ((type :accessor %standard-clef-type
j@190 229 :initarg :type)
j@190 230 (line :accessor %standard-clef-line
j@190 231 :initarg :line)
j@190 232 (octave-shift :accessor %standard-clef-octave-shift
j@190 233 :initarg :octave-shift
j@190 234 :initform nil))
j@190 235 (:documentation "Class of clef with slots for type (a keyword
j@190 236 from :F, :G and :C, probably), line (counting from the lowest line =
j@190 237 1) and octave shift (nil or a positive or negative integer
j@190 238 representing transposition up or down"))
j@190 239
j@190 240 (defclass standard-clef-period (standard-clef clef-period standard-anchored-period)
j@190 241 ()
j@190 242 (:documentation "Standard clef on a timeline"))