Jump to content

pattern-match with overwrite


Recommended Posts

dear all

i'll try to code a function that overwrites the SEQ with an insert after a pattern-match... not so simple, because to calculate all the length-values in the SEQ so that there ist no "shifting" ist very....

 

here an easy sketch... but with a simple, so that i haven't got to calculate (beacuse all is mapped on quaternotes)...

i hope anyone could CODE that... would be an interesting FUNCTION!!! using things as a NET!!

 

compare -> seq with the function output... the you see the idea

 

 

(setf seq '(e c4 -e -q q d4 -q s c4 -e. -h. q))

(setf insert '(3q c4 d4 e4 c4 d4 e4 c4 d4 -3q))
(setf insert-span (loop for i in (omn :length insert)
                    sum (abs i)))

(progn
  (setf new-list
        (loop for i in (single-events seq)
          with match = 0
          when (pattern-matchp i '(q d4 ?)) do (setf match 1)
          when (= match 1)
          collect (abs (car (omn :length i))) into bag
          
          when (and (= match 1) (<= (sum bag) insert-span)) collect (* -1 (abs (car (omn :length i))))
          else collect i
          
          ))

  (flatten (loop for x in new-list
             with match = 0
             when (and (atom x) (= match 0)) collect insert and do (setf match 1)
             when (listp x) collect x)))

 

Link to comment
Share on other sites

sorry, but this would be easy (for beginners :smile:)

...but that's not correct because it is INSERTRED and not OVERWRITED... 

 

there is NO function in OM that's doing this. 

greetings from "helmut" :bigsmile: ...because if you want work with "strukturnetze" you have to keep the NET correct and not to shift the time values (how it is with pattern-map)... so you have to overwrite

Link to comment
Share on other sites

You need to explain the process a bit better.

Should the span after the process stay of the original sequence?

Is the insert (which it is) should complete the span with there own loop etc...

All this is simple to code if the process is known :-)

 

added 7 minutes later

Your example:


 

;; seq
(e c4 -e -q q c4 -q s c4 -e. q)

;; insert
(3q c4 d4 e4 c4 d4 e4 c4 d4)

;; pattern-match
(q c4)

 

result in block

(e c4 -e -q) (3q c4 d4 e4 c4 d4 e4 c4 d4) (-3q q c4)

from where is the last list coming from?

Link to comment
Share on other sites

(setf seq '(e c4 -e -q q d4 -q s q d4 c4 e. q d4 h. q))
(setf insert '(3q c4 d4 e4 c4 d4 e4 c4 d4 -3q))
(setf insert-span (get-span insert))
(setf match '(q d4 ?))

Your code returns:

(e c4 mf -e -q 3q c4 d4 e4 c4 d4 e4 c4 d4 -3q q d4 mf q c4 mf e. c4 mf q d4 mf h. d4 mf q d4 mf)

?

Link to comment
Share on other sites

sorry but with this code - evaluating all i have...

only for THIS input-seq ... you input-seq seems different

 


(setf seq '(e c4 -e -q q d4 -q s c4 -e. -h. q))

(setf insert '(3q c4 d4 e4 c4 d4 e4 c4 d4 -3q))
(setf insert-span (loop for i in (omn :length insert)
                    sum (abs i)))

(progn
  (setf new-list
        (loop for i in (single-events seq)
          with match = 0
          when (pattern-matchp i '(q d4 ?)) do (setf match 1)
          when (= match 1)
          collect (abs (car (omn :length i))) into bag 
          when (and (= match 1) (<= (sum bag) insert-span)) collect (* -1 (abs (car (omn :length i))))
          else collect i
          
          ))

  (flatten (loop for x in new-list
             with match = 0
             when (and (atom x) (= match 0)) collect insert and do (setf match 1)
             when (listp x) collect x)))
                                       
                                       
 => (e c4 mf -e -q 3q c4 d4 e4 c4 d4 e4 c4 d4 -3q -h. q c4 mf)
            

 

Link to comment
Share on other sites

i see 4 possibilities...

1) you could work in generations => only 1 match per gen => but it could end in a stack overflow (when it's recursiv, when match is also inside the insert)

2) could overwrite in generations from last to first match -> means right to left in the list (but not with matches inside the insert) => so when it's more then one match it will be overlapping

3) could generate overlaying voices by few matches

4) you could limited it by &key :nooverlapping 't

added 4 minutes later

if it will work, i wll code a nice example for OM to present it :smile:

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