Jump to content

Recommended Posts

Posted

something i've coded...

 

(defun binary-filter (alist bin-list)
  (let ((event-list (cond ((omn-formp alist)
                           (single-events alist))
                          (t alist))))
    (flatten 
     (loop 
       for i in event-list
       for j in bin-list
       when (= j 1)
       collect i
       else append (cond ((omn-formp i)
                          (list (length-invert (car i))))
                         ((lengthp i)
                          (neg! (omn :length (list i)))))))))


(binary-filter '(q -q -q q) '(0 1 0 1))
=> (-1/4 -q -1/4 q)
(binary-filter '(q q q q -q) '(0 1 0 1 1))
=> (-1/4 q -1/4 q -q)
(binary-filter '(c4 d4 e4 f4) '(1 1 0 1))
=> (c4 d4 f4)
(binary-filter '(q c4 mf  d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1))
=> (q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp)

 

Posted

Hi André

Just investigating your function..
Then I've tried a little cosmetic hack to make it more readable, but it did not work out and I don't understand why. What did I overlook?

Thanks!

 

ole

;;; the orginal function 

(defun binary-filter (alist bin-list)
  (let ((event-list (cond ((omn-formp alist)
                           (single-events alist))
                          (t alist))))
    (flatten 
     (loop 
       for i in event-list
       for j in bin-list
       when (= j 1)
       collect i
       else append (cond ((omn-formp i)
                          (list (length-invert (car i))))
                         ((lengthp i)
                          (neg! (omn :length (list i)))))))))





(binary-filter '(q c4 mf  d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1))
=> (q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp)




;;;Why is it not working??



(defun foo-rep (n sequence &key omn)
  (maybe-omn-decode omn
   (binary-filter n sequence)))


(foo-rep '(q c4 mf  d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1) :omn t)
-->(q c4 mf -1/4 q e4 mf e f4 ppp -1/8 e a4 ppp e b4 ppp);??



 

Posted
(defun binary-filter (alist bin-list &key (omn t))
  (let ((event-list (cond ((omn-formp alist)
                           (single-events alist))
                          (t alist))))
    (flatten 
     (loop 
       for i in event-list
       for j in bin-list
       when (= j 1)
       collect i
       else append
       (maybe-omn-decode
        omn
        (cond ((omn-formp i) (list (length-invert (car i))))
              ((lengthp i)  (neg! (omn :length (list i))))))))))

(binary-filter '(q c4 mf d4 e4 e f4 ppp g4 a4 b4) '(1 0 1 1 0 1 1))
=> (q c4 mf -q q e4 mf e f4 ppp -e e a4 ppp e b4 ppp)

 

Only one type of parameters can be decoded at a time.

Posted

I wanted to call my own function like that -

"Error: The function binary-invert is predefined by Opusmodus."

 

also:

(binary-invert '(0 8 0 2 2))
=> (1 0 1 0 0)

 

janusz? 😉

 

Posted

Predefined functions can't be changed otherwise you would break the system.
The binary-invert is sub function of binary-variant.

(binary-variant '(0 1 1 0 1 0 1 1) 'i)
=> (1 0 0 1 0 1 0 0)

 

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