Jump to content

length-to-decimal / length-to-sec


Recommended Posts

two functions i needed for working with POLYTEMPO-NETWORK

 

http://philippekocher.ch/#109

http://polytempo.zhdk.ch

 

greetings

andré

 

(defun length-to-decimal (alist &key (sum nil))
  (let ((list (loop for i in (omn :length alist)
                collect (float (* i 4)))))
      (if (equal sum t)
      (sum list)
      list)))

;;; result: q = 1 / h. = 3 ...etc...
(length-to-decimal '(h. h. 3q 5e 3h))
=> (3.0 3.0 0.33333334 0.1 0.6666667)

(length-to-decimal '(h. h. 3q 5e 3h) :sum t)
=> 7.1

(defun length-to-sec (alist tempo &key (sum nil))
  (let ((list (loop for i in (omn :length alist)
                collect (* (/ 60 tempo) (float (* i 4))))))
    (if (equal sum t)
      (sum list)
      list)))

(length-to-sec '(h. h. 3q 5e 3h) 60)
=> (3.0 3.0 0.33333334 0.1 0.6666667)

(length-to-sec '(h. h. 3q 5e 3h) 51)
=> (3.5294118 3.5294118 0.3921569 0.11764707 0.7843138)

(length-to-sec '(h. h. 3q 5e 3h) 51 :sum t)
=> 8.3529415

 

Link to comment
Share on other sites

I used this function for conversion of 4 instrument each with in its own tempo to one 'global' tempo.

 

Examples:

(length-tempo-map 72 36 '1/4)
=> 1/2

(length-tempo-map 72 36 'w)
=> 2

(length-tempo-map 72 88 '(1/8 1/4 -1/4))
=> (9/88 9/44 -9/44)

(length-tempo-map 72 '(120 36)
                  '((1/8 1/4 -1/4) (1/16 1/8 -1/4 1/1)))
=> ((3/40 3/20 -3/20) (1/8 1/4 -1/2 2))

(length-tempo-map 72 '(36 96 72)
                  '((1/20 1/20 1/20 1/20 1/20) 
                    (1/16 1/16 1/16 1/16 1/16 1/16 1/16 1/16)
                    (1/8 1/8 1/8 1/8)
                    (1/4 1/4 1/4 1/4 1/4 1/4 1/4 1/4))
                  :meter '(1 1 1))
=> ((1/10 1/10 1/10 1/10 1/10)
    (1/8 1/8 1/8 1/8 1/8 1/8 1/8 1/8) 
    (1/4 1/4 3/32 3/32)
    (3/16 3/16 3/16 1/4 1/4 1/4 1/4 1/2))

(length-tempo-map 72 36 '((e c4 e4 g4 h_e c5)
                          (q c4 = = - - =)
                          (q cs5 = - - = =)))
=> ((q c4 e4 g4 w_q c5)
    (h c4 = = - - =)
    (h cs5 = - - = =))

(length-tempo-map 72 '(36 96 72)
                  '((e c4 e4 g4 h_e c5)
                    (q c4 = = - - =)
                    (q cs5 = - - = =))
                  :meter '(1 1 1))
=> ((q c4 e4 g4 w_q c5)
    (e. c4 = = - -q =)
    (q cs5 = -h - = =))
Link to comment
Share on other sites

  • 7 months later...

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