Jump to content
Sign in to follow this  
AM

filter-events-by-length

Recommended Posts

you can filter all events by length (>= min).

all other events will be replaced by rests...

 


(defun filter-events-by-length (omnlist &key min)
  (let ((omnlist (single-events omnlist))
        (min (car (omn :length (list min)))))
    (flatten 
     (length-rest-merge 
      (loop for i in omnlist
        when (>= (car (omn :length i)) min)
        collect i
        else collect (neg! (car (omn :length i))))))))


(filter-events-by-length '(e c4 d4 e4 e5 q c4 d4 e4 h c4 d4 e4) :min 'e)
=> (e c4 mf e d4 mf e e4 mf e e5 mf q c4 mf q d4 mf q e4 mf h c4 mf h d4 mf h e4 mf)

(filter-events-by-length '(e c4 d4 e4 e5 q c4 d4 e4 h c4 d4 e4) :min 'q)
=> (-h q c4 mf q d4 mf q e4 mf h c4 mf h d4 mf h e4 mf)

(filter-events-by-length '(e c4 d4 e4 e5 q c4 d4 e4 h c4 d4 e4) :min 'h)
=> (-wq h c4 mf h d4 mf h e4 mf)

 

 

Share this post


Link to post
Share on other sites

@janusz: you could expand it with conditionals like >, <, =, span .... and implement it....

and... if you would write this function with conditionals for pitches (sequences of pitches) you could filter by vector-envelope...

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  

×