Jump to content

filter-events with patterns -> filter-pattern?


Recommended Posts

violà, take it as a sketch...

 

;;; like this, but the question is how to structure the input-values
;;; the kind of structure decides about output...

(defun filter-pattern (pattern omn-list)
  (progn
    (if (atom (car pattern))
      (setf pattern (mapcar #'list pattern)))
    (flatten 
     (loop 
       for i in (single-events omn-list)
       with cnt = 0
       
       when (pattern-matchp i (nth cnt pattern))
       collect i and do (incf cnt)
       else collect (neg! (omn :length i))
       
       when (= cnt (length pattern)) do (setf cnt 0)))))
  

(setf seq '(e c4 mp -e fermata e. d4 -h e. c4 e e4))


(filter-pattern (rnd-sample-seq 2 (single-events seq)) 
                '(e c4 mp -e fermata e. d4 -h e. c4 e e4))

(filter-pattern '((e. c4) (e4))
                '(e c4 mp -e fermata e. d4 -h e. c4 e e4))

(filter-pattern '((c4) (e4))
                '(e c4 mp -e fermata e. d4 -h e. c4 e e4))

(filter-pattern '(c4 e4)
                '(e c4 mp -e fermata e. d4 -h e. c4 e e4))

 

Link to comment
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.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy