Jump to content

Interval distance of a list (integers or pitches) in relation to a chosen note


Recommended Posts

Dear All, 

 

Is there a function for get all intervals of a row (or any list of integers or pitches) in relation to one note ?

For example, given this 12 tone row:

(a3 gs4 c4 d4 bb3 b3 fs4 f4 cs4 g4 ds4 e4)

Get all intervals related to a4 ?

The result should be:

 

(-12 -1 -9 -7 -11 -10 -3 -4 -8 -2 -6 -5)

 

This is for getting a resultant set of numbers related to a chromatic octave-module. Each order of the set result in a different set.

Maybe can be a mapping function.

 

Link to comment
Share on other sites


(defun interval-distance (alist n)
  (let ((alist (if (pitchp (car alist))
                 (pitch-to-midi alist)
                 alist))
        (n (if (pitchp n)
             (pitch-to-midi n)
             n)))

    (loop for i in alist
      collect (- i n))))
    
(interval-distance '(c4 d4 b2 e7) 'c4)
=> (0 2 -13 40)
(interval-distance '(c4 d4) 'c4)
=> (0 2)
(interval-distance '(43 44) '41)
=> (2 3)
(interval-distance '(56 48 11) 'c4)
=> (-4 -12 -49)

 

Edited by AM
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy