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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×