Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

pattern-match with overwrite

Featured Replies

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)))

 

(setf map '(((q d4 ?) (3q c4 d4 e4 c4 d4 e4 c4 d4 -3q))))
(pattern-map map '(e c4 -e -q q d4 -q s c4 -e. -h. q))
=> (e c4 -e -q 3q c4 d4 e4 c4 d4 e4 c4 d4 -3q s c4 -e. -h. q)

:smile:

  • Author

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

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?

  • Author

an example:

IMG_5873.JPG

This example (above) is simple insert.

I like you to explain this:

 

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

from where is the last list coming from?

 

  • Author

last list is THE END of the original seq! last quarternote (which is not overwrited by the insert)

What will happen if there are few matches: (q d4 ?)

(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))

 

  • Author

i think it has to works in GENERATIONS

 

added 2 minutes later

my result is.... with my code is... (no sublists)

 

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

 

(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)

?

  • Author

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)
            

 

  • Author

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:

  • Author

... in the future... do exist such a function in OM...?

greetings

andré

Create an account or sign in to comment


Copyright © 2014-2026 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.