Jump to content
Sign in to follow this  
AM

reset-pitch-sequence

Recommended Posts

reset a pitch-sequence on a specific pitch (lowest, highest, middle pitch of the sequence)

 

;;;; SUB


(defun center-position-in-list (list &key (get-value 'nil))
  (let ((pos))
    (progn
      (setf pos (if (evenp (length list))
                  (/ (length list) 2)
                  (/ (1+ (length list)) 2)))
      (if (equal get-value 'nil)
        (append pos)
        (nth (1- pos) list)))))


;;; MAIN

(defun reset-pitch-sequence (pitch-sequence pitch &key (type 'low))
  (let ((pitch1 (cond  ((equal type 'low)
                        (car (find-ambitus pitch-sequence :type :pitch)))
                       ((equal type 'high)
                        (cadr (find-ambitus pitch-sequence :type :pitch)))
                       ((equal type 'center) 
                        (center-position-in-list pitch-sequence :get-value t)))))
    (pitch-transpose (car (pitch-to-interval (list (if (chordp pitch1)
                                                     (car (pitch-melodize pitch1))
                                                     (append pitch1))
                                                   pitch))) pitch-sequence)))



(reset-pitch-sequence '(gs2 g2 a2 fs2 ds2 f2 e2) 'fs3 :type 'low)
=> (b3 bb3 c4 a3 fs3 gs3 g3)

(reset-pitch-sequence '(gs2 g2 a2 fs2 ds2 f2 e2) 'fs3 :type 'high)
=> (f3 e3 fs3 eb3 c3 d3 cs3)

(reset-pitch-sequence '(gs2 g2 a2 fs2 ds2 f2 e2) 'fs3 :type 'center)
=> (f3 e3 fs3 eb3 c3 d3 cs3)

 

 

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...