diff methods.lisp @ 18:70e76c1c87b7

Bug fixes and exports in package.lisp darcs-hash:20061213114049-f76cc-4c4175a1ad8b24e1c5df82c9fb67445ac32977d9.gz
author David Lewis <d.lewis@gold.ac.uk>
date Wed, 13 Dec 2006 11:40:49 +0000
parents 930e9880ed3f
children 2f331bbdfab8
line wrap: on
line diff
--- a/methods.lisp	Tue Dec 12 14:44:22 2006 +0000
+++ b/methods.lisp	Wed Dec 13 11:40:49 2006 +0000
@@ -9,6 +9,15 @@
 (defmethod span ((pitch-interval-designator pitch-interval))
   (%pitch-interval-span pitch-interval-designator))
 
+(defmethod chromatic-pitch ((pitch-designator chromatic-pitch))
+  pitch-designator)
+
+(defmethod chromatic-pitch-number ((pitch-designator chromatic-pitch))
+  (%chromatic-pitch-number pitch-designator))
+
+(defmethod chromatic-pitch-number ((pitch-designator pitch))
+  (%chromatic-pitch-number (chromatic-pitch pitch-designator)))
+
 ;; Time protocol
 
 (defmethod time+ ((object1 moment) (object2 period))
@@ -25,9 +34,9 @@
   (error 'undefined-action :operation 'time+ :datatype (list (class-of object1) (class-of object2))))
 
 (defmethod time- ((object1 moment) (object2 moment))
-  (make-anchored-period object1
-			(- (duration object2)
-			   (duration object1))))
+  (make-anchored-period (timepoint object2)
+			(- (timepoint object1)
+			   (timepoint object2))))
 
 (defmethod time- ((object1 moment) (object2 period))
   (make-moment (- (timepoint object1) (duration object2))))
@@ -41,6 +50,19 @@
   (make-floating-period (- (duration object2)
 			   (duration object1))))
 
+;; these ones are less certain. I've just put them in, but think I
+;; should remove them and force the user to specify what they mean
+;; when they give objects that are both moments *and* periods to these
+;; functions.
+
+(defmethod time- ((object1 anchored-period) (object2 anchored-period)) ;? 
+  (time- (moment object1) (moment object2)))
+
+(defmethod time- (object1 (object2 anchored-period)) ;?
+  (time- object1 (moment object2)))
+
+(defmethod time- ((object1 anchored-period) object2) ;?
+  (time- (moment object1) object2))
 
 (defmethod time> ((object1 moment) (object2 moment))
   (> (timepoint object1) (timepoint object2)))
@@ -55,13 +77,13 @@
   (= (duration object1) (duration object2)))
 
 (defmethod duration* ((object1 period) (object2 number))
-  (* (duration object1) object2))
+  (make-floating-period (* (duration object1) object2)))
 
 (defmethod duration* ((object1 number) (object2 period))
   (duration* object2 object1))
 
 (defmethod duration/ ((object1 period) (object2 number))
-  (/ (duration object1) object2))
+  (make-floating-period (/ (duration object1) object2)))
 
 ;; Pitch protocol