< Back to IRCAM Forum

Omloop programing question

Hallo!

I have a programming question:

I have a list
(1 2 3 4 5 6 7 8)
and I have a list that I use for filtering of the previous list:
(1 2 nil nil nil 6 7 8)
I want to get the result
(1 2 12 6 7 8)

In other words I need to know how to make a loop, that would trigger the accumulation (accumulative addition) of the numbers of the original list at places that are nil in the filtering list.
(I want to use this function to add together the filtered durations from a list.)

Please, can you help me out here?

I kindly ask you to give your answer in graphical programming!

Best regards!

Aliser

Hi Aliser,

The answer for your question doesn’t concern omloop, but the formulation of the problem.

If you need what you want, it’s simpler to :

Group your list following n segments, them apply the sum of each.

Here is my solution. Tell me if it’s good for you .

Best
K

Patch-3.omp.zip (761 Bytes)

Dear Karim,

Thank you for answering so quickly!
Yet, my incoming filter-list is in format (1 2 nil nil nil 6 7 8), as a result of multiple previous filtrations. I am trying to built a function that would sum the filtered values and the non filtered values would be just passed. So the real list is (very long) list of durations and nils. (Perhaps is my example too simplified.) Even if I would try to “translate” filter-list into group-list, I would have make a loop to count nil and non-nil elements of the list, what requires the same method as the one I was asking for and I don’t know the way to make it. (Or maybe I am wrong?)

I also have previously encountered a need to build u loop (or a function) that could apply accumulation only on triggered parts of a processed list while the rest would be passed. Is that obtainable in OM, or there is some other method then the loop?

Thank you once more, and many regards!

Aliser

Dear Aliser,

It is possible of course. But I am afraid the formulation of your problem makes it possible only in lisp code. Doing this in graphical programing (patch) could be very heavy and might output a stack overflow since you have apparently a long list.

Maybe if we figure out the filtering first or what are you up to (i believe you want to concatenate durations) it will be easier graphically.
Can you send a simple patch of your filtering process. (please make it simple).

Best
K

Dear Karim,

I found the solution for my question based on your suggestion from previous mail. It is a quite work-around, but it works. (I am sending to you a patch with my solution. If you have easier or better one, please let me know!)

I am still asking myself would the method of loop (or a function) that could apply accumulation on triggered parts of a processed list be easier.

I would really appreciate if you could send to me any loop example (even only in lisp-code) that applies accumulation on triggered parts of a processed list.

Thank you very much for your kindness, help and invested time!

Aliser

tie-pitch-repetiton.omp (72.5 KB)

Hi Aliser.

As Karim notes, the easiest solution is probably to reformulate the problem. However, it’s always intriguing with questions getting the ‘your thinking is wrong’ answer, esp. w. a tool like OM, which is designed to provide a dwim approach :slight_smile:

Using loop is difficult when you want to change the graph dynamically. Recursive programming is well suited however.
I’ve attached a patch, together with a call (and lisp versions of the same thing).

Cheers,

Anders.

check.omp (1.25 KB)

Dear Anders,

Thank you very much for your answer, patches and lisp file!

Thanks to Karim, I reformulated the problem, but I was still interested in learning the way to graphically build a patch that would apply a function only on parts of a list while the rest of the list is passed. I have encountered such a need for many times. Thanks to you, now I know the answer to that question.

(I hope one day there will be some kind of OM documentation or tutorials that would include more complex examples of graphical programming and musically relevant LISP programming suited for musicians with little or no programming experience.)

Thank you again and all the best!

Aliser

Dear Aliser,

I have in preparation a new set of tutorials based on Om users questions that i hope i will release sometime in the future.
Concerning some loop and recursive programing, i advise you to learn some lisp. It is far more easier sometimes to put it in code than to program it visualy. That’s why you have in Om some coded functions. For instance Anders’ very fine solution to your problem, if you compare the complexity of lisp coding and Om patching, you will realize that it’s far more elegant and clear to use the Lisp code in such circumstance. That is basically why i told you sometime , reconsidering our musical approach to the problem, can make it easier to achieve our goal.

I will let you know about the progress of the new tutorials.

BEst to you all !
K