diff base/generics.lisp @ 136:fd85f52d9f9d

Class revolution * PITCH-DESIGNATOR -> PITCH (PITCH removed) * MOMENT-DESIGNATOR -> MOMENT , MOMENT -> STANDARD-MOMENT * PERIOD-DESIGNATOR -> PERIOD , PERIOD -> STANDARD-PERIOD * ANCHORED-PERIOD-DESIGNATOR -> ANCHORED-PERIOD , ANCHORED-PERIOD -> STANDARD-ANCHORED-PERIOD * FLOATING-PERIOD removed * TIME-SIGNATURE-DESIGNATOR -> TIME-SIGNATURE & TIME-SIGNATURE-PERIOD * TIME-SIGNATURE -> STANDARD-TIME-SIGNATURE & STANDARD-TIME-SIGNATURE-PERIOD * KEY-SIGNATURE-DESIGNATOR -> KEY-SIGNATURE (& ...-PERIOD) * KEY-SIGNATURE -> STANDARD-KEY-SIGNATURE (& ...-PERIOD) * TEMPO now abstract (& TEMPO-PERIOD) * STANDARD-TEMPO AND STANDARD-TEMPO-PERIOD * COMPOSITION, CONSTITUENT & TIME-ORDERED-CONSTITUENT all have STANDARD- forms make-x methods and specialisers changes appropriately darcs-hash:20070831142943-f76cc-7be0d08963de06d87b36e4922076287d565c7ee2.gz
author David Lewis <d.lewis@gold.ac.uk>
date Fri, 31 Aug 2007 15:29:43 +0100
parents 5e362d998f29
children ebfe054eea1c
line wrap: on
line diff
--- a/base/generics.lisp	Tue Aug 28 11:17:27 2007 +0100
+++ b/base/generics.lisp	Fri Aug 31 15:29:43 2007 +0100
@@ -41,82 +41,83 @@
 
 (defgeneric pitch (object &key kind)) ; ? Maybe this returns the pitch
 				      ; in its ur form?
-(defgeneric chromatic-pitch (pitch-designator))
-(defgeneric diatonic-pitch (pitch-designator))
+(defgeneric chromatic-pitch (pitch))
+(defgeneric diatonic-pitch (pitch))
 (defgeneric frequency (object)) ;?
 
-(defgeneric octave (pitch-designator)
+(defgeneric octave (pitch)
   (:documentation "Return an integer representing the octave of
-pitch-designator where middle c is defined to be the lowest pitch in
+pitch where middle c is defined to be the lowest pitch in
 octave 4."))
 
-(defgeneric diatonic-pitch-octave (pitch-designator)
+(defgeneric diatonic-pitch-octave (pitch)
   (:documentation "Return an integer representing the diatonic octave
-of PITCH-DESIGNATOR."))
+of pitch."))
 
-(defgeneric diatonic-pitch-accidental (pitch-designator)
+(defgeneric diatonic-pitch-accidental (pitch)
   (:documentation "Return an integer representing the inflection of a
 diatonic pitch where where negative values indicate numbers of flats,
 0 indicates natural and positive values indicate numbers of sharps."))
 
-(defgeneric diatonic-pitch-mp (pitch-designator)
+(defgeneric diatonic-pitch-mp (pitch)
   (:documentation "Return an integer representing the morphetic pitch
 \(in MIPS terms) of a diatonic pitch."))
-(defgeneric diatonic-pitch-cp (pitch-designator)
+(defgeneric diatonic-pitch-cp (pitch)
   (:documentation "Return an integer representing the chromatic pitch
 \(in MIPS terms) of a diatonic pitch."))
 
-(defgeneric middle-c (pitch-designator) 
+(defgeneric middle-c (pitch) 
   (:documentation "Returns the value of middle C in the particular
-representation of pitch used by PITCH-DESIGNATOR."))
-(defgeneric midi-pitch-number (pitch-designator)
-  (:documentation "Takes a pitch-designator (usually a pitched
-  event) and returns an integer between 0 and 127 representing
-  the chromatic pitch designated (60=middle C, 48 the C below
-  that, etc.)"))
-(defgeneric asa-pitch-string (pitch-designator)
+representation of pitch used by PITCH."))
+(defgeneric midi-pitch-number (pitch)
+  (:documentation "Takes a pitch (usually a pitched event) and
+  returns an integer between 0 and 127 representing the chromatic
+  pitch represented (60=middle C, 48 the C below that, etc.)"))
+(defgeneric asa-pitch-string (pitch)
   (:documentation "Returns a string representing the designated ASA
 pitch name which has three parts: a letter name in the set
 {A,B,C,D,E,F,G}, an inflection in the set {n,f,s,ff,ss,fff,sss,...}
 and an octave number. E.g., Cn4 = Middle C."))
-(defgeneric asa-interval-string (pitch-designator)
+(defgeneric asa-interval-string (pitch)
   (:documentation "Returns a string representing the designated ASA
 interval name which has two or three parts: a direction in the set
 {r,f} (absent for unisons/primes), a type in the set
 {p,ma,mi,a,d,aa,dd,aaa,ddd,...}, and a size number.  E.g. rma2 =
 rising major second."))
-(defgeneric diatonic-pitch-name (pitch-designator)
+(defgeneric diatonic-pitch-name (pitch)
   (:documentation "Returns a char in the set
 {#\A,#\B,#\C,#\D,#\E,#\F,#\G}, representing the pitch name of
-PITCH-DESIGNATOR."))
-(defgeneric pitch-class (pitch-designator)
-  (:documentation "Takes a pitch-designator (usually a pitched
-  event) and returns an integer between 0 and 12 representing
-  the octave-independant pitch, with c=0, c#=1, etc.")
+PITCH."))
+(defgeneric pitch-class (pitch)
+  (:documentation "Takes a pitch (usually a pitched event) and
+  returns an integer between 0 and 12 representing the
+  octave-independant pitch, with c=0, c#=1, etc.")
   (:method (p) (mod (midi-pitch-number p) 12)))
-(defgeneric span (pitch-interval-designator))
+(defgeneric span (pitch-interval))
 
 ;; time
 
-(defgeneric duration (period-designator)
-  (:documentation "Returns a value. Probably should only apply do
-  periods (rather than designators?)"))
-(defgeneric (setf duration) (value period-designator)
-  (:documentation "As with duration, should probably work only
-  with periods"))
-(defgeneric timepoint (moment-designator)
-  (:documentation "Returns a value for a moment. Does this make
-  any sense on a designator?"))
-(defgeneric (setf timepoint) (value moment-designator)
-  (:documentation "Sets timepoint. What does this mean for a
-  designator?"))
-(defgeneric cut-off (anchored-period-designator) ; name?
+(defgeneric duration (period)
+  (:documentation "Returns a real. Probably should only apply do
+  standard-periods (rather than periods? or should it return
+  something other than a value in other cases)"))
+(defgeneric (setf duration) (value period)
+  (:documentation "As with duration, perhaps this should work only
+  with standard-periods"))
+(defgeneric timepoint (moment)
+  (:documentation "Returns a number for a moment. Does this make
+  any sense on an abstrace class? Should it just apply to
+  standard-moment?"))
+(defgeneric (setf timepoint) (value moment)
+  (:documentation "Sets timepoint. What does this mean for an
+ abstract class? Should it just apply to standard-moment"))
+(defgeneric cut-off (anchored-period) ; name?
   (:documentation "Returns a <moment> representing the point at
   which the anchored period has ended. By default, is calculated
   as the result of running time+ on the onset and period of the
   object.")
-  (:method (apd) (time+ (moment apd) (floating-period apd))))
-(defgeneric crotchet (object) 
+  (:method (apd) (time+ (moment apd) (period apd))))
+(defgeneric crotchet (object)
   (:documentation "Returns a period, the duration of which represents
 a crotchet in the time representation used by object."))
 
@@ -180,24 +181,24 @@
 ;; be direct slot accessors or the generics I'm using? Should we
 ;; return the object itself if it already is in the target class?
 
-(defgeneric anchored-period (anchored-period-designator)
+(defgeneric anchored-period (anchored-period)
   (:method (apd) (make-anchored-period (onset apd) (duration apd)))
   (:documentation "Coerce any anchored period to a plain anchored
   period"))
 
-(defgeneric floating-period (period-designator)
-  (:method (pd) (make-floating-period (duration pd)))
+(defgeneric period (period)
+  (:method (pd) (make-period (duration pd)))
   (:documentation "Coerce any period to a floating period"))
 
-(defgeneric moment (moment-designator)
+(defgeneric moment (moment)
   (:method (md) (make-moment (timepoint md)))
-  (:documentation "Coerce any moment(-designator?), including an
+  (:documentation "Coerce any moment, including an
   anchored-period to a moment"))
 
-(defgeneric onset (anchored-period-designator)
+(defgeneric onset (anchored-period)
   (:method (apd) (moment apd))
   (:documentation "Return a moment for the start of an anchored period"))
-(defgeneric (setf onset) (value anchored-period-designator))
+(defgeneric (setf onset) (value anchored-period))
 
 ;;; Time Protocol (or moments?)
 
@@ -215,55 +216,55 @@
 ;;        <anchored>  <anchored> -> (time- (moment o1) (moment o2)) ? or error?
 
 (defgeneric time+ (object1 object2)
-  (:documentation "Addition for time designators"))
+  (:documentation "Addition for time objects"))
 (defgeneric time- (object1 object2)
-  (:documentation "Subtraction for time designators"))
+  (:documentation "Subtraction for time objects"))
 
 (defgeneric time> (object1 object2)
-  (:documentation "> operator for moment designators"))
+  (:documentation "> operator for moments"))
 (defgeneric time< (object1 object2)
-  (:documentation "< operator for moment designators")
+  (:documentation "< operator for moments")
   (:method (o1 o2) (time> o2 o1)))
 (defgeneric time= (object1 object2)
-  (:documentation "= operator for moment designators")) 
+  (:documentation "= operator for moments")) 
 (defgeneric time>= (object1 object2)
-  (:documentation ">= operator for moment designators")
+  (:documentation ">= operator for moments")
   (:method (o1 o2) (or (time> o1 o2) (time= o1 o2))))
 (defgeneric time<= (object1 object2)
-  (:documentation "<= operator for moment designators")
+  (:documentation "<= operator for moments")
   (:method (o1 o2) (or (time< o1 o2) (time= o1 o2))))
 (defgeneric time/= (object1 object2)
-  (:documentation "not = operator for moment designators")
+  (:documentation "not = operator for moments")
   (:method (o1 o2) (not (time= o1 o2))))
 
 ;;; Duration protocol 
 
 (defgeneric duration> (object1 object2)
-  (:documentation "> operator for period designators"))
+  (:documentation "> operator for periods"))
 (defgeneric duration< (object1 object2)
-  (:documentation "< operator for period designators")
+  (:documentation "< operator for periods")
   (:method (o1 o2) (duration> o2 o1)))
 (defgeneric duration= (object1 object2)
-  (:documentation "= operator for period designators")) 
+  (:documentation "= operator for periods")) 
 (defgeneric duration>= (object1 object2) 
-  (:documentation ">= operator for period designators")
+  (:documentation ">= operator for periods")
   (:method (o1 o2) (or (duration> o1 o2) (duration= o1 o2))))
 (defgeneric duration<= (object1 object2)
-  (:documentation "<= operator for period designators")
+  (:documentation "<= operator for periods")
   (:method (o1 o2) (or (duration< o1 o2) (duration= o1 o2))))
 (defgeneric duration/= (object1 object2) 
-  (:documentation "not = operator for period designators")
+  (:documentation "not = operator for periods")
   (:method (o1 o2) (not (duration= o1 o2))))
 
 ;; for linear scaling:
 (defgeneric duration* (object1 object2)
-  (:documentation "Multiplication operator for period
-  designators. Intuitively, this makes sense, but it may cause us
+  (:documentation "Multiplication operator for
+  periods. Intuitively, this makes sense, but it may cause us
   trouble with some implementations in the future."))
 (defgeneric duration/ (object1 number)
-  (:documentation "Division operator for period designators. This
-  may turn out not to mean much. Division is probably useful, but
-  we may need to define what we mean with care."))
+  (:documentation "Division operator for periods. This may turn
+  out not to mean much. Division is probably useful, but we may
+  need to define what we mean with care."))
 
 ;;; Pitch protocol 
 
@@ -336,19 +337,19 @@
   (:method (ap s) (remove-if #'(lambda (x) (amuse:disjoint ap x)) s)))
 
 ;; Return the anchored-period representing the intersection of two
-;; anchored-period-specifiers.
-(defgeneric period-intersection (anchored-period-specifier1
-				 anchored-period-specifier2))
+;; anchored-period.
+(defgeneric period-intersection (anchored-period1
+				 anchored-period2))
 
-(defgeneric inter-onset-interval (moment-designator1 moment-designator2)
-  (:method (md1 md2) (time- (moment md2) (moment md1))))
+(defgeneric inter-onset-interval (moment1 moment2)
+  (:method (moment1 moment2) (time- (moment moment2) (moment moment1))))
 
 
 ;;; Time Signature 
 
 (defgeneric get-applicable-time-signatures (anchored-period composition)
   (:method (ap c) (find-overlapping ap (time-signatures c)))
-  (:documentation "Return a list of time-signatures that are
+  (:documentation "Return a list of TIME-SIGNATURE-PERIODs that are
   relevant to <anchored-period>. The period may contain
   information such as staff position and voicing, and the method
   may use this to filter its response"))
@@ -361,10 +362,10 @@
 
 (defgeneric get-applicable-tempi  (anchored-period composition)
   (:method (ap c) (find-overlapping ap (tempi c)))
-  (:documentation "Return a list of tempi that are relevant to
-  <anchored-period>. The period may contain information such as
-  staff position and voicing, and the method may use this to
-  filter its response"))
+  (:documentation "Return a list of TEMPO-PERIODs that are
+  relevant to <anchored-period>. The period may contain
+  information such as staff position and voicing, and the method
+  may use this to filter its response"))
 
 (defgeneric tempo-equal (t1 t2)
   (:documentation "Comparison operator. The definition of
@@ -373,7 +374,7 @@
 ;;; Tonality (Key Signature / Mode) 
 
 (defgeneric get-applicable-key-signatures (object1 object2)
-  (:documentation "Return a list of key-signatures that are
+  (:documentation "Return a list of KEY-SIGNATURE-PERIODs that are
   relevant to <anchored-period>. The period may contain
   information such as staff position and voicing, and the method
   may use this to filter its response"))
@@ -382,6 +383,18 @@
   (:documentation "Comparison operator. The definition of
   equality is left open to implementers"))
 
+;;; Some generic constructors - are these useful? (DL 31/8/07)
+(defgeneric make-moment (value)
+  (:documentation "Returns MOMENT of subclass appropriate to the
+  class of value. Probably guessed."))
+(defgeneric make-period (value)
+  (:documentation "Returns PERIOD of subclass appropriate to the
+  class of value. Probably guessed."))
+(defgeneric make-anchored-period (start-value duration-value)
+  (:documentation "Returns ANCHORED-PERIOD of subclass
+  appropriate to the class of value. Probably guessed."))
+
+
 ;;; Dynamics 
 ;;; Voice 
 ;;; Boundary Strength (phrasing)