annotate base/classes.lisp @ 146:a74494a94be9

implementations/midi: implement MONODY for midi files darcs-hash:20070924160443-c0ce4-302ec7f06335a374b673f70ef2e79d4b2a8b3616.gz
author Marcus Pearce <m.pearce@gold.ac.uk>
date Mon, 24 Sep 2007 17:04:43 +0100
parents b753a56c373b
children 8156c30c0c53
rev   line source
m@24 1 (cl:in-package #:amuse)
m@24 2
m@124 3 ;; top-level amuse object
m@24 4
m@125 5 (defclass amuse-object () ())
m@24 6
m@24 7 ;; types of information-specifiers
m@24 8
m@125 9 (defclass identifier (amuse-object) ()) ;; for composition specification
d@136 10 (defclass moment (amuse-object) ()
d@100 11 (:documentation "Object indicating a point in time"))
d@136 12 (defclass period (amuse-object) ()
d@100 13 (:documentation "Object indicating a region of time"))
d@136 14 (defclass anchored-period (moment period) ()
d@100 15 (:documentation "Object indicating a region of time starting at
d@100 16 a specific point in time"))
d@136 17 (defclass pitch (amuse-object) ()
d@100 18 (:documentation "Object indicating some sort of pitch"))
d@136 19 (defclass pitch-interval (amuse-object) ()
d@100 20 (:documentation "Object indicating a distance in pitch space"))
m@24 21
m@24 22 ;; time-related classes
m@24 23
d@136 24 (defclass standard-moment (moment)
d@100 25 ((time :accessor %moment-time :initarg :time))
d@136 26 (:documentation "A moment that has time represented on a
d@136 27 continuous, progressive number line"))
m@24 28
d@136 29 (defclass standard-period (period)
d@100 30 ((interval :accessor %period-interval :initarg :interval))
d@136 31 (:documentation "A period that places time intervals
d@136 32 on a progressive number-line"))
m@24 33
d@136 34 (defclass standard-anchored-period (standard-period standard-moment anchored-period) ()
d@100 35 (:documentation "Number-line-based anchored period"))
m@24 36
m@24 37 ;; pitch-related classes
m@24 38
d@136 39 (defclass frequency-pitch (pitch) ())
m@24 40
m@24 41 (defclass chromatic-pitch (pitch)
d@100 42 ((number :accessor %chromatic-pitch-number :initarg :number))
d@123 43 (:documentation "A pitch represented as a number, with
d@123 44 chromatic pitches having distinct values."))
c@109 45 (defclass diatonic-pitch (pitch)
c@108 46 ((cp :initarg :cp :accessor %p-pc :reader diatonic-pitch-cp)
c@108 47 (mp :initarg :mp :accessor %p-pm :reader diatonic-pitch-mp))
c@109 48 (:documentation "A diatonic pitch, represented using MIPS: cp is an
c@109 49 integer representing chromatic pitch (An0 = 0, middle C = 39); mp is
c@109 50 an integer representing the morphetic pitch (An0 = 0, middle C =
c@109 51 23)."))
m@81 52
d@136 53 (defclass chromatic-pitch-interval (pitch-interval)
d@138 54 ((span :accessor %chromatic-pitch-interval-span :initarg :span))
d@138 55 (:documentation "An interval represented as a number, recording
d@138 56 the number of ascending chromatic pitches between two pitches."))
c@111 57
d@136 58 (defclass diatonic-pitch-interval (pitch-interval)
d@138 59 ((span :accessor %diatonic-pitch-interval-span :initarg :span :reader span))
d@138 60 (:documentation "How is this inplemented?"))
m@24 61
m@24 62 ;; events
m@24 63
d@122 64 (defclass event (anchored-period) ()
d@122 65 (:documentation "Notelike object"))
d@136 66 (defclass pitched-event (event pitch) ()
d@136 67 (:documentation "Event with pitch information"))
d@136 68 (defclass standard-pitched-event (pitched-event
d@136 69 standard-anchored-period) ()
d@122 70 (:documentation "Event with pitch information"))
d@122 71 (defclass chromatic-pitched-event (pitched-event chromatic-pitch) ()
d@122 72 (:documentation "Event with chromatic pitch information"))
d@136 73 (defclass standard-chromatic-pitched-event (chromatic-pitched-event
d@136 74 standard-anchored-period) ()
d@136 75 (:documentation "Event with chromatic pitch information and
d@136 76 standard-period"))
d@122 77 (defclass percussive-event (event) ()
d@134 78 (:documentation "Unpitched percussion Event. There's an issue
d@134 79 with this name - is there a reason why this is unpitched
d@134 80 necessarily, or why I'm not counting piano, etc in this? Perhaps
d@136 81 what I mean is that it should be renamed unpitched-event?
d@136 82 Actually, is this necessary? Isn't this just an event?"))
d@136 83 (defclass standard-percussive-event (event standard-anchored-period) ()
d@136 84 (:documentation "Unpitched percussion Event. There's an issue
d@136 85 with this name - is there a reason why this is unpitched
d@136 86 necessarily, or why I'm not counting piano, etc in this? Perhaps
d@136 87 what I mean is that it should be renamed unpitched-event?
d@138 88 Actually, is this necessary? Isn't this just an event?
d@138 89 Timbral/instrumental information will be generalised later but is
d@138 90 less agreed-on than pitch."))
m@24 91
m@24 92 ;;; Range-based `constituents'
m@24 93 ;; Whilst these are all constituents in the CHARM sense, their
m@24 94 ;; properties apply to a timed range rather than to a set of
m@24 95 ;; events. As such, they can be regarded as anchored-periods with
m@24 96 ;; properties.
m@24 97
d@136 98 (defclass time-signature (amuse-object) ()
d@136 99 (:documentation "Abstract class for time signature"))
m@24 100
d@136 101 (defclass time-signature-period (time-signature anchored-period) ()
d@136 102 (:documentation "Abstract class for time signatures in time"))
d@136 103
d@136 104 (defclass standard-time-signature (time-signature)
m@24 105 ((numerator :accessor %basic-time-signature-numerator
m@24 106 :initarg :numerator)
m@24 107 (denominator :accessor %basic-time-signature-denominator
d@123 108 :initarg :denominator))
d@123 109 (:documentation "Class with slots for numerator and
d@123 110 denominator. Can only deal with numeric signatures."))
m@24 111
d@136 112 (defclass standard-time-signature-period (standard-time-signature
d@136 113 time-signature-period
d@136 114 standard-anchored-period)
d@136 115 ()
d@136 116 (:documentation "STANDARD-TIME-SIGNATURE on a time number line"))
d@136 117
d@136 118 (defclass key-signature (amuse-object) ()
d@123 119 (:documentation "Base class for key signature"))
m@24 120
d@136 121 (defclass key-signature-period (key-signature anchored-period) ()
d@136 122 (:documentation "Abstract class for time signatures in time"))
d@136 123
d@136 124 (defclass standard-key-signature (key-signature)
m@24 125 ((sharp-count :accessor %basic-key-signature-sharp-count
d@123 126 :initarg :sharp-count))
d@123 127 (:documentation "Simple class - Only has line-of-fifths
d@123 128 distance from c, so custom signatures won't work"))
m@24 129
d@136 130 (defclass standard-key-signature-period (standard-key-signature
d@136 131 key-signature-period
d@136 132 standard-anchored-period)
d@136 133 ()
d@136 134 (:documentation "STANDARD-KEY-SIGNATURE on a time number line"))
d@136 135
d@136 136 (defclass midi-key-signature (standard-key-signature)
m@40 137 ((mode :accessor %midi-key-signature-mode
d@123 138 :initarg :mode))
d@123 139 (:documentation "MIDI-based flavour of basic key signature,
d@123 140 adding a slot for mode: 0 = major key; 1 = minor key"))
m@40 141
d@136 142 (defclass midi-key-signature-period (standard-key-signature-period
d@136 143 midi-key-signature)
d@136 144 ()
d@136 145 (:documentation "MIDI-KEY-SIGNATURE on a time number line"))
d@136 146
d@136 147 (defclass tempo (amuse-object) ()
d@136 148 (:documentation "Abstract class for tempo"))
d@136 149 (defclass tempo-period (tempo anchored-period) ()
d@136 150 (:documentation "Abstract class for tempo associated with a
d@136 151 time period"))
d@136 152 (defclass standard-tempo (tempo)
m@24 153 ((bpm :accessor %tempo-bpm
d@123 154 :initarg :bpm))
d@123 155 (:documentation "Rather literal reading of absolute tempo.
d@123 156 accel and rit in symbolic encoding will need other structures,
d@123 157 as will textual tempo markings."))
d@136 158 (defclass standard-tempo-period (standard-tempo
d@136 159 tempo-period
d@136 160 standard-anchored-period)
d@136 161 ()
d@136 162 (:documentation "Tempo associated with a standard-anchored-period"))
m@40 163
m@124 164 ;; collections of more than one event
m@124 165
m@124 166 (defclass constituent (anchored-period) ())
d@136 167 (defclass standard-constituent (constituent standard-anchored-period) ())
m@124 168 (defclass time-ordered-constituent (constituent list-slot-sequence)
m@124 169 ;; this won't work if lisp implementation doesn't support extensible
m@124 170 ;; sequences.
m@124 171 ())
d@136 172 (defclass standard-time-ordered-constituent (time-ordered-constituent
d@136 173 standard-constituent
d@136 174 list-slot-sequence)
d@136 175 ;; this won't work if lisp implementation doesn't support extensible
d@136 176 ;; sequences.
d@136 177 ())
m@124 178 (defclass composition (time-ordered-constituent) ())
d@136 179 (defclass standard-composition (composition
d@136 180 standard-time-ordered-constituent) ())
m@124 181 (defclass monody (composition) ())
m@143 182 (defclass standard-monody (monody standard-composition) ())