Jump to content

shift-length-proportions / morph


Recommended Posts

shift-length-proportions 

 

a bit like gen-morph for LENGTHS. every item of a length-list will change linear till the endpattern is reached.

 

 


;;; subfunction

(defun compare (start end &key (step 1/32))
  (list (loop 
          for i in start
          for j in end
          
          when (/= i j)
          collect (if (> i 0)
                    (if (< i j)
                      (+ i step)
                      (- i step))
                    (if (> i j)
                      (- i step)
                      (+ i step)))
                    
          else collect i)
        end))


;;; mainfunction

(defun shift-length-proportions (start end &key (step 1/32) (rnd-pick nil))
  (let ((seq))
    (progn 
      (setf seq
            (progn 
              (setf start (omn :length start)
                    end (omn :length end))
              (append (list start)
                      (loop until (equal start end)
                        collect (setf start (car (compare start end :step step)))))))
  (if (or (null rnd-pick) (equal rnd-pick 'all))
    seq
    (rnd-sample rnd-pick seq)))))
  

;;; EXAMPLES

(shift-length-proportions '(1/32 7/32 1/16 3/16 1/4 -1/2) '(1/16 1/16 1/16 1/16 1/16 -1/2) :step 1/32)
(shift-length-proportions '(1/16 1/16 1/16 1/16 1/16 -1/2) '(1/16 7/32 1/16 3/16 1/4 -1/2)  :step 1/32)


(shift-length-proportions '(1/32 7/32 1/16 3/16 1/4 -1/2) '(1/16 1/16 1/16 1/16 1/16 -1/2) :step 1/32 :rnd-pick 3)
(shift-length-proportions '(1/32 7/32 1/16 3/16 1/4 -1/2) '(1/16 1/16 1/16 1/16 1/16 -1/2) :step 1/32 :rnd-pick 4)
(shift-length-proportions '(e q h e.. s -h) '(q q q q q -h) :step 1/32 :rnd-pick 3)


 

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