Jump to content
Sign in to follow this  
JulioHerrlein

Help needed Binary Length values

Recommended Posts

Dear Friends,

 

1) How to convert a given length series in a binary series ? For example:

((1/16 -3/16 1/16 -1/8 1/16 -1/4)) with 1/16 as a base could be transformed in binary like:

(1 0 0 0 1 0 0 1 0 0 0 0)

 

and/or

2) How to convert a length  3/16 in 1/16 -1/16 -1/16, i.e. a kind of length conversion

 based on quantize.

 

3/16 could be converted in

 

1/16 -1/16 -1/16

or

1/32 -1/32 -1/32 -1/32 -1/32 -1/32

depending on the value regarded as the reference (1/16 in the first case or 1/32 in the second)

 

Thanks !

Julio

 

Code example

(setf ccpa1 (omn :length (length-staccato 1/16 (time-point-system (pitch-rotate 0 (pcs '3-11b :pitch))'s :start 0))))

;EXTRA FUNCTION NEEDED

;;;LENGTH-LEGATO (by ANDRE MEIER)

(defun length-staccato (n alist)
  (let ((newlengths)
        (new-omn (omn-merge-ties (flatten  alist)))
        (time-sign (get-time-signature alist)))
    (progn 
      (setf newlengths (loop for i in (omn :length new-omn)
                         when (> i 0)
                         append (if (= n i)
                                  (list i)
                                  (list n (* -1 (abs (- i n)))))
                         
                         else collect i))
      (if (omn-formp alist)
        (omn-to-time-signature (make-omn :length newlengths
                                         :pitch (omn :pitch new-omn)
                                         :velocity (omn :velocity new-omn)
                                         :articulation (omn :articulation new-omn))
                               time-sign)
        newlengths))))

 

 

Share this post


Link to post
Share on other sites

something like that?

 

(defun length-to-binary (lengthlist n)
  (let ((newlist (loop for i in (omn :length lengthlist)
                    collect (/ i n))))
    (loop for x in newlist
      when (> x 0)
      append (append (list 1) (gen-repeat (1- x) '0))
      else append  (gen-repeat (abs x) '0))))
    

(length-to-binary '(-q q e) 1/16)
=> (0 0 0 0 1 0 0 0 1 0)

(length-to-binary '(-q s s q e) 1/16)
=> (0 0 0 0 1 1 1 0 0 0 1 0)

 

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