Mercurial > hg > amuse
changeset 86:7a0ee88f1edb
base/: new generics DIATONIC-PITCH-ACCIDENTAL and OCTAVE
darcs-hash:20070717165105-c0ce4-9f6acb06961d3413ceca604ca0285ababcdda377.gz
author | Marcus Pearce <m.pearce@gold.ac.uk> |
---|---|
date | Tue, 17 Jul 2007 17:51:05 +0100 |
parents | c81375b9304f |
children | 19a263fb92d1 |
files | base/generics.lisp base/methods.lisp base/package.lisp |
diffstat | 3 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/base/generics.lisp Tue Jul 17 17:49:46 2007 +0100 +++ b/base/generics.lisp Tue Jul 17 17:51:05 2007 +0100 @@ -39,6 +39,16 @@ (defgeneric mips-pitch (pitch-designator)) (defgeneric frequency (object)) ;? +(defgeneric octave (pitch-designator) + (:documentation "Return an integer representing the octave of +pitch-designator where middle c is defined to be the lowest pitch in +octave 4.")) + +(defgeneric diatonic-pitch-accidental (pitch-designator) + (: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 middle-c (pitch-designator) (:documentation "Returns the value of middle C in the particular representation of pitch used by PITCH-DESIGNATOR."))
--- a/base/methods.lisp Tue Jul 17 17:49:46 2007 +0100 +++ b/base/methods.lisp Tue Jul 17 17:51:05 2007 +0100 @@ -2,6 +2,12 @@ ;;; diatonic pitch +(defmethod octave ((dp diatonic-pitch)) + (%diatonic-pitch-octave dp)) + +(defmethod diatonic-pitch-accidental ((dp diatonic-pitch)) + (%diatonic-pitch-accidental dp)) + (defmethod pitch= ((p1 diatonic-pitch) (p2 diatonic-pitch)) (let ((n1 (%diatonic-pitch-name p1)) (a1 (%diatonic-pitch-accidental p1)) @@ -47,6 +53,12 @@ ;;; MIPS pitch +(defmethod octave ((mp mips-pitch)) + (octave (diatonic-pitch mp))) + +(defmethod diatonic-pitch-accidental ((mp mips-pitch)) + (diatonic-pitch-accidental (diatonic-pitch mp))) + (defmethod pitch= ((p1 mips-pitch) (p2 mips-pitch)) (let ((c1 (meredith-chromatic-pitch-number p1)) (m1 (meredith-morphetic-pitch-number p1)) @@ -95,6 +107,9 @@ ;;; Chromatic pitch +(defmethod octave ((cp chromatic-pitch)) + (1- (/ (%chromatic-pitch-number cp) 12))) + (defmethod middle-c ((cp chromatic-pitch)) (make-chromatic-pitch 60))