Jump to content

some functions


Recommended Posts

here some functions (that i'm using currently). perhaps anyone/OPMO would include/optimze them.. take the ideas...

greetings

andré

 

1) rnd-order/sort-omn => picks omn-seqs/bars in rnd-order and sorting it (a mix-up and sort-process for OMN) 

 

(defun rnd-order/sort-omn (omnlist &key (type nil) (sort 'a) (step nil))
  (let* ((int-seq (gen-integer 0 (1-(length omnlist))))
         (sorted-int (gen-sort (rnd-order int-seq) :type type :sort sort :step step)))

    (loop for i in (flatten sorted-int)
      collect (nth i omnlist))))

(rnd-order/sort-omn '((w c4 mf) (h d4 ppp ten  e4 ten) (q g4 leg a4 leg b4 leg) (e c5 d5 e5 f5 g5)))
=> ((q g4 leg a4 leg b4 leg) (w c4 mf) (h d4 ppp ten e4 ten) (e c5 d5 e5 f5 g5) (w c4 mf) (q g4 leg a4 leg b4 leg) (h d4 ppp ten e4 ten) (e c5 d5 e5 f5 g5) (w c4 mf) (h d4 ppp ten e4 ten) (q g4 leg a4 leg b4 leg) (e c5 d5 e5 f5 g5))

 

 

 

 

2) filter-events by pitch (in all octaves!) / pos and neg

 

;; SUB

(defun p-octaves (plist)
  (loop for i in '(-48 -36 -24 -12 0 12 24 36 48)
    append (pitch-transpose i plist)))

;;; MAINS
(defun filter-events-pos (pitchlist omnlist)
  (loop 
    for i in (single-events omnlist)
    
    when (null (member (second i) (p-octaves pitchlist)))
    collect '(-1/32) else collect i))


(defun filter-events-neg (pitchlist omnlist)
  (loop 
    for i in (single-events omnlist)
    
    when (null (member (second i) (p-octaves pitchlist)))
    collect i else collect '(-1/32)))


;;;;;

(filter-events-pos '(c4 d4 g4) '(t c4 mf cs4 d4 eb4 e4 f4 fs4 g4 gs4 a4 bb4 b4))
=> ((t c4 mf) (-1/32) (t d4 mf) (-1/32) (-1/32) (-1/32) (-1/32) (t g4 mf) (-1/32) (-1/32) (-1/32) (-1/32))

(filter-events-neg '(c4 d4 g4) '(t c4 mf cs4 d4 eb4 e4 f4 fs4 g4 gs4 a4 bb4 b4))
=> ((-1/32) (t cs4 mf) (-1/32) (t eb4 mf) (t e4 mf) (t f4 mf) (t fs4 mf) (-1/32) (t gs4 mf) (t a4 mf) (t bb4 mf) (t b4 mf))

 

 

 

 

 

Link to comment
Share on other sites

Something similar, only valid for the given octave, but taking the length into account and can handle pitch repetitions and list of lists, no negative/inversed function though:

 

(defun mute-pitch-event (pch omnlist)
 
(let* ((pos (position-item pch (omn :pitch (flatten omnlist))))
       (poslen (position-filter pos (omn :length (flatten omnlist))))
       (new (position-replace pos (mapcar #'(lambda (x)(* -1 x)) poslen) 
                             (omn :length (flatten omnlist)))))
             (if (some #'listp omnlist)
             (gen-divide (mapcar 'length (omn :pitch omnlist))
             (make-omn :length new
            :pitch (omn :pitch (flatten omnlist))
            :swallow t))
               (make-omn :length new
            :pitch (omn :pitch omnlist)
            :swallow t))))

;;;;-testing-;;;;;

(setf test '(t c4 mf cs4 d4  eb4 e eb4 e4 f4 fs4 q g4 s gs4 a4 bb4 b4))
(mute-pitch-event 'eb4 test)

 

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