annotate base/classes.lisp @ 68:95dce8c7f08c

midi-key-signature: 0 darcs-hash:20070706094145-c0ce4-eedb2b03b6557c4dba4cdd1170c925c471744a71.gz
author Marcus Pearce <m.pearce@gold.ac.uk>
date Fri, 06 Jul 2007 10:41:45 +0100
parents f308c2b7b796
children 4e1538df0d10
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) ())
d@33 11 (defclass monody (time-ordered-constituent) ())
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)))
m@24 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@24 43 (octave :accessor %diatonic-pitch-octave :initarg :octave)))
m@24 44
m@24 45 (defclass pitch-interval (pitch-interval-designator)
m@24 46 ((span :accessor %pitch-interval-span :initarg :span)))
m@24 47
m@24 48 ;; events
m@24 49
m@24 50 (defclass event (anchored-period) ())
m@24 51 (defclass pitched-event (event pitch-designator) ())
m@24 52 (defclass chromatic-pitched-event (pitched-event chromatic-pitch) ())
m@24 53 (defclass percussive-event (event) ())
m@24 54
m@24 55 ;;; Range-based `constituents'
m@24 56 ;; Whilst these are all constituents in the CHARM sense, their
m@24 57 ;; properties apply to a timed range rather than to a set of
m@24 58 ;; events. As such, they can be regarded as anchored-periods with
m@24 59 ;; properties.
m@24 60
m@24 61 (defclass time-signature (anchored-period) ())
m@24 62
m@48 63 (defclass basic-time-signature (time-signature)
m@24 64 ;; N.B. Can only deal with numeric signatures
m@24 65 ((numerator :accessor %basic-time-signature-numerator
m@24 66 :initarg :numerator)
m@24 67 (denominator :accessor %basic-time-signature-denominator
m@24 68 :initarg :denominator)))
m@24 69
m@24 70 (defclass key-signature (anchored-period) ())
m@24 71
m@24 72 (defclass basic-key-signature (key-signature)
m@24 73 ;; Only has line-of-fifths distance from c, so custom signatures
m@24 74 ;; won't work
m@24 75 ((sharp-count :accessor %basic-key-signature-sharp-count
m@44 76 :initarg :sharp-count)))
m@24 77
m@40 78 (defclass midi-key-signature (basic-key-signature)
m@68 79 ;; mode: 0 = major key; 1 = minor key
m@40 80 ((mode :accessor %midi-key-signature-mode
m@44 81 :initarg :mode)))
m@40 82
m@57 83 (defmethod print-object ((mks midi-key-signature) stream)
m@57 84 (format stream "#<~A ~A ~A>"
m@57 85 (symbol-name (class-name (class-of mks)))
m@57 86 (%basic-key-signature-sharp-count mks)
m@57 87 (%midi-key-signature-mode mks)))
m@57 88
m@24 89 (defclass tempo (anchored-period)
m@24 90 ;; accel and rit in symbolic encoding will need other structures, as
m@24 91 ;; will textual tempo markings.
m@24 92 ((bpm :accessor %tempo-bpm
m@24 93 :initarg :bpm)))
m@40 94