annotate base/classes.lisp @ 89:0b4c624910f1

base/: basic protocol for accessing monodies darcs-hash:20070723140651-c0ce4-2c828ea984eb92f0ccb73866a6a496131c8fa736.gz
author Marcus Pearce <m.pearce@gold.ac.uk>
date Mon, 23 Jul 2007 15:06:51 +0100
parents 8ea75cc8bc2c
children ad9cca28fecf
rev   line source
m@24 1 (cl:in-package #:amuse)
m@24 2
m@24 3 ;; collections of more than one event
m@24 4
d@33 5 (defclass constituent (anchored-period) ())
d@33 6 (defclass time-ordered-constituent (constituent list-slot-sequence)
d@33 7 ;; this won't work if lisp implementation doesn't support extensible
d@33 8 ;; sequences.
d@33 9 ())
d@33 10 (defclass composition (time-ordered-constituent) ())
m@89 11 (defclass monody (composition) ())
m@24 12
m@24 13 ;; types of information-specifiers
m@24 14
d@35 15 (defclass identifier () ()) ;; for composition specification
m@24 16 (defclass moment-designator () ())
m@24 17 (defclass period-designator () ())
m@24 18 (defclass anchored-period-designator (moment-designator period-designator) ())
m@24 19 (defclass pitch-designator () ())
m@24 20 (defclass pitch-interval-designator () ())
m@24 21
m@24 22 ;; time-related classes
m@24 23
m@24 24 (defclass moment (moment-designator)
m@24 25 ((time :accessor %moment-time :initarg :time)))
m@24 26
m@24 27 (defclass period (period-designator)
m@24 28 ((interval :accessor %period-interval :initarg :interval)))
m@24 29
m@24 30 (defclass floating-period (period) ())
m@24 31 (defclass anchored-period (period moment anchored-period-designator) ())
m@24 32
m@24 33 ;; pitch-related classes
m@24 34
m@24 35 (defclass frequency () ())
m@24 36
m@24 37 (defclass pitch (pitch-designator) ())
m@24 38 (defclass chromatic-pitch (pitch)
m@24 39 ((number :accessor %chromatic-pitch-number :initarg :number)))
d@88 40 (defclass diatonic-pitch (pitch)
m@24 41 ((name :accessor %diatonic-pitch-name :initarg :name)
m@24 42 (accidental :accessor %diatonic-pitch-accidental :initarg :accidental)
m@81 43 (octave :accessor %diatonic-pitch-octave :initarg :octave))
m@81 44 (:documentation "NAME is an integer between 0-6, representing the
m@81 45 note name A-G; ACCIDENTAL is an integer where negative values indicate
m@81 46 numbers of flats, 0 indicates natural and positive values indicate
m@81 47 numbers of sharps; and octave is an integer indicating the ASA octave
m@81 48 number (the lowest full octave of the piano starting with C is octave
m@81 49 1, so the lowest note on the piano is A0; middle C is C4, and
m@81 50 the note just below it is B3)."))
m@81 51
m@81 52 (defclass mips-pitch (pitch)
m@81 53 ((cp :initarg :cp :accessor %p-pc)
m@81 54 (mp :initarg :mp :accessor %p-pm))
m@81 55 (:documentation "A MIPS pitch: cp is an integer representing
m@81 56 chromatic pitch (An0 = 0, middle C = 39); mp is an integer
m@81 57 representing the morphetic pitch (An0 = 0, middle c = 23)."))
m@81 58
m@24 59 (defclass pitch-interval (pitch-interval-designator)
m@24 60 ((span :accessor %pitch-interval-span :initarg :span)))
m@24 61
m@24 62 ;; events
m@24 63
m@24 64 (defclass event (anchored-period) ())
m@24 65 (defclass pitched-event (event pitch-designator) ())
m@24 66 (defclass chromatic-pitched-event (pitched-event chromatic-pitch) ())
m@24 67 (defclass percussive-event (event) ())
m@24 68
m@24 69 ;;; Range-based `constituents'
m@24 70 ;; Whilst these are all constituents in the CHARM sense, their
m@24 71 ;; properties apply to a timed range rather than to a set of
m@24 72 ;; events. As such, they can be regarded as anchored-periods with
m@24 73 ;; properties.
m@24 74
m@24 75 (defclass time-signature (anchored-period) ())
m@24 76
m@48 77 (defclass basic-time-signature (time-signature)
m@24 78 ;; N.B. Can only deal with numeric signatures
m@24 79 ((numerator :accessor %basic-time-signature-numerator
m@24 80 :initarg :numerator)
m@24 81 (denominator :accessor %basic-time-signature-denominator
m@24 82 :initarg :denominator)))
m@24 83
m@24 84 (defclass key-signature (anchored-period) ())
m@24 85
m@24 86 (defclass basic-key-signature (key-signature)
m@24 87 ;; Only has line-of-fifths distance from c, so custom signatures
m@24 88 ;; won't work
m@24 89 ((sharp-count :accessor %basic-key-signature-sharp-count
m@44 90 :initarg :sharp-count)))
m@24 91
m@40 92 (defclass midi-key-signature (basic-key-signature)
m@68 93 ;; mode: 0 = major key; 1 = minor key
m@40 94 ((mode :accessor %midi-key-signature-mode
m@44 95 :initarg :mode)))
m@40 96
m@57 97 (defmethod print-object ((mks midi-key-signature) stream)
m@57 98 (format stream "#<~A ~A ~A>"
m@57 99 (symbol-name (class-name (class-of mks)))
m@57 100 (%basic-key-signature-sharp-count mks)
m@57 101 (%midi-key-signature-mode mks)))
m@57 102
m@24 103 (defclass tempo (anchored-period)
m@24 104 ;; accel and rit in symbolic encoding will need other structures, as
m@24 105 ;; will textual tempo markings.
m@24 106 ((bpm :accessor %tempo-bpm
m@24 107 :initarg :bpm)))
m@40 108