[CM] pclass and mathematics of harmony

John J Foerch jjfoerch@earthlink.net
Thu, 05 Jan 2006 18:25:07 -0500


Hello,

I'm a cmn newbie intrigued by the idea of using Lisp to
generate music.  My goal is to make functions that can be
used in a cmn score that will generate or modify notes,
using the mathematics of harmony.  Here is a method I am
workin on, that adjusts the cclass of a note object:

(defmethod cclass-shift ((obj note) (amt integer))

  "Shift OBJ note up or down AMT tones in the current key.
For example, amt=1 shifts the note up by an interval of a
second, and amt=7 shifts it up by an octave.  Still need to
work out setting the pitch correctly.  "

  (let* ((new-cclass    (mod   (+ (cclass obj) amt) 7))
         (octave-adjust (floor (+ (cclass obj) amt) 7))
         (new-octave    (+ (octave obj) octave-adjust))
         (pclass (case new-cclass
                   (0 0)
                   (1 2)
                   (2 4)
                   (3 5)
                   (4 7)
                   (5 9)
                   (6 11)
                   )))
    (setf (cclass obj) new-cclass)
    (setf (octave obj) new-octave)
    (setf (pitch obj) pclass)
    obj))


I use this method in a score, like:

    (cclass-shift (note a2) 1)

My question concerns the setting of the pclass.  To do it
correctly I need to know the key signature accidental for
the line of the new cclass.  Is the key signature data
available to a lowly little note on the staff?  If not, is
this a worthy and possible feature request?  Or is there a
better approach to the problem than this?

Thank you for any help!

John J Foerch