Jump to content
Sign in to follow this  
AM

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

 

Share this post


Link to post
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 - = =))

Share this post


Link to post
Share on other sites

Janusz, where is this above function 'length-tempo-map'?

 

It doesn't appear to be part of system and system/forum searches only come up with this one reference?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

function name changed to length-to-tempo

 

 

 

 

Share this post


Link to post
Share on other sites

The new name is length-to-tempo - for some time 🙂

Share this post


Link to post
Share on other sites

Thank you for the info and replies ;-)

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...