view base/classes.lisp @ 134:5e362d998f29

More documentation darcs-hash:20070828101524-f76cc-6add2c3c254befc3cf767ac69706865b7830bc6a.gz
author David Lewis <d.lewis@gold.ac.uk>
date Tue, 28 Aug 2007 11:15:24 +0100
parents c179481a7bd0
children fd85f52d9f9d
line wrap: on
line source
(cl:in-package #:amuse) 

;; top-level amuse object 

(defclass amuse-object () ())

;; types of information-specifiers

(defclass identifier (amuse-object) ()) ;; for composition specification
(defclass moment-designator (amuse-object) ()
  (:documentation "Object indicating a point in time"))
(defclass period-designator (amuse-object) ()
  (:documentation "Object indicating a region of time"))
(defclass anchored-period-designator (moment-designator period-designator) ()
  (:documentation "Object indicating a region of time starting at
  a specific point in time"))
(defclass pitch-designator (amuse-object) ()
  (:documentation "Object indicating some sort of pitch"))
(defclass pitch-interval-designator (amuse-object) ()
  (:documentation "Object indicating a distance in pitch space"))

;; time-related classes

(defclass moment (moment-designator) 
  ((time :accessor %moment-time :initarg :time))
  (:documentation "A moment-designator that has moments in time
  represented on a number line"))

(defclass period (period-designator) 
  ((interval :accessor %period-interval :initarg :interval))
  (:documentation "A period-designator that places time intervals
  on a number-line"))

(defclass floating-period (period) ()
  (:documentation "A simple numeric period"))
(defclass anchored-period (period moment anchored-period-designator) ()
  (:documentation "Number-line-based anchored period"))

;; pitch-related classes

(defclass frequency () ())

(defclass pitch (pitch-designator) ())
(defclass chromatic-pitch (pitch) 
  ((number :accessor %chromatic-pitch-number :initarg :number))
  (:documentation "A pitch represented as a number, with
  chromatic pitches having distinct values."))
(defclass diatonic-pitch (pitch) 
  ((cp :initarg :cp :accessor %p-pc :reader diatonic-pitch-cp)
   (mp :initarg :mp :accessor %p-pm :reader diatonic-pitch-mp))
  (:documentation "A diatonic pitch, represented using MIPS: cp is an
integer representing chromatic pitch (An0 = 0, middle C = 39); mp is
an integer representing the morphetic pitch (An0 = 0, middle C =
23)."))

(defclass chromatic-pitch-interval (pitch-interval-designator) 
  ((span :accessor %chromatic-pitch-interval-span :initarg :span)))

(defclass diatonic-pitch-interval (pitch-interval-designator)
  ((span :accessor %diatonic-pitch-interval-span :initarg :span :reader span)))

;; events

(defclass event (anchored-period) ()
  (:documentation "Notelike object"))
(defclass pitched-event (event pitch-designator) ()
  (:documentation "Event with pitch information"))
(defclass chromatic-pitched-event (pitched-event chromatic-pitch) ()
  (:documentation "Event with chromatic pitch information"))
(defclass percussive-event (event) ()
  (:documentation "Unpitched percussion Event. There's an issue
with this name - is there a reason why this is unpitched
necessarily, or why I'm not counting piano, etc in this? Perhaps
what I mean is that it should be renamed unpitched-event?"))

;;; Range-based `constituents'
;; Whilst these are all constituents in the CHARM sense, their
;; properties apply to a timed range rather than to a set of
;; events. As such, they can be regarded as anchored-periods with
;; properties.

(defclass time-signature (anchored-period) ()
  (:documentation "Base class for time signature"))

(defclass basic-time-signature (time-signature)
  ((numerator :accessor %basic-time-signature-numerator
	      :initarg :numerator)
   (denominator :accessor %basic-time-signature-denominator
		:initarg :denominator))
  (:documentation "Class with slots for numerator and
  denominator. Can only deal with numeric signatures."))

(defclass key-signature (anchored-period) ()
  (:documentation "Base class for key signature"))

(defclass basic-key-signature (key-signature)
  ((sharp-count :accessor %basic-key-signature-sharp-count
		:initarg :sharp-count))
  (:documentation "Simple class - Only has line-of-fifths
  distance from c, so custom signatures won't work"))

(defclass midi-key-signature (basic-key-signature)
  ((mode :accessor %midi-key-signature-mode
	 :initarg :mode))
  (:documentation "MIDI-based flavour of basic key signature,
  adding a slot for mode: 0 = major key; 1 = minor key"))

(defclass tempo (anchored-period)
  ((bpm :accessor %tempo-bpm
	:initarg :bpm))
  (:documentation "Rather literal reading of absolute tempo.
  accel and rit in symbolic encoding will need other structures,
  as will textual tempo markings."))
   
;; collections of more than one event

(defclass constituent (anchored-period) ())
(defclass time-ordered-constituent (constituent list-slot-sequence)
  ;; this won't work if lisp implementation doesn't support extensible
  ;; sequences.
  ())
(defclass composition (time-ordered-constituent) ())
(defclass monody (composition) ())