< Back to IRCAM Forum

Iterative process determined by its own output

Hello,
I am new to OpenMusic, so I apologize if this is a basic question or is covered elsewhere, but I couldn’t find it in the documentation. I’m trying to generate a list of numbers which employs a variety of semi-randomized processes. The first number should be randomly selected between 2 and 11, all the following numbers should be determined by the number preceding them, and the list should end when a number is equal to its position in the list (i.e. the fourth item is “4”), or else when the length of the list is 11 items. So if a number in the list n is even (and is not identical to its position in the list), the following number will either be 3/2n or n/2 + 1 (which generative procedure is used for the following number is randomized). If n is odd the procedures are different.
I figured out the first step—generating the second number of the list on the basis of the first (randomly selected) number—and have attached a screenshot of that, to give a better idea of what I’m looking for (the second “omif” function makes sure that the number generated is between 2 and 11). But I’m struggling to figure out how to turn this into an iterative process, so that an entire list is generated simply from one user-evaluation. I tried playing around with the accum object in omloop, but I can’t figure out how to make it so that the “list” in the first input is itself generated by a process that, at each step of the iteration, evaluates the outcome of the previous step, nor how to make it so that the first step of the iteration evaluates a different input—namely the result of the om-random at the top of the screenshot.
I hope I have been clear enough in my description of this—let me know if there are any necessary clarifications, and thanks in advance for the help.
Theo

Dear theokoskoff,

Very interesting problem. However could you:

  1. post the patch you got in the screenshot (this will make us gain some time to reproduce)
  2. can you post also a result as an example. because it is unclear for me your explanation about “position in list” and what is related to all the below:
    " all the following numbers should be determined by the number preceding them, and the list should end when a number is equal to its position in the list (i.e. the fourth item is “4”), or else when the length of the list is 11 items. So if a number in the list n is even (and is not identical to its position in the list), the following number will either be 3/2n or n/2 + 1 (which generative procedure is used for the following number is randomized). If n is odd the procedures are different."

Best
K

Hey,
Idk if you already saw this:
https://support.ircam.fr/docs/om/om6-manual/co/LoopExample.html
but it’s a good example to make random series with constraints imo.
best,
rc

1 Like

Thank you for the quick response!
As I’m a new user I can only attach one screenshot per post, so I will have to post multiple times. Here is a screenshot of the “ifeven” patch…

…here is the “ifodd” patch…

…and here is a list of a number of evaluations of the “list” box from the screenshot in my original post.
As you can see the results are thus far lists of two elements each. I am trying to make it so that, for example, for the first result “(4 6)”, the value “6” is fed back as the input through the network in the original screenshot (instead of “om-random”) resulting in some number n, and the resulting list would be (4 6 n). Then n would be the new input for the next iteration, etc.
For the result “(8 2)”, however, I would like the list to stop, because the last number “2” is also in the second place in the list (i.e. the total length of the list is equal to its final number). I am pretty sure I know how to do this using either “forloop” or “whileloop” and a combination of “nth”, “length” and “om-” functions, though I may end up running into some issues when I try it out. My problem at the moment is that I can’t even get to that point, because I can’t figure out how to turn this into an iterative process.
Screenshot 2024-05-09 at 6.02.53 PM

Yes, I saw this, and it helped me to an extent but does not solve my main problem, because in this example the procedure for generating list elements is identical for each step of the iteration. I am trying to design an iterative process where the generation of each item in a list is partly determined by the previous item in the list, i.e. by the previous step in the iteration.

Dear theokoskof

First of all i am sorry for the inconvenience that you cannot post the patch. This is a very silly restriction.

I have taken some time builidng your patch however, there are some missing blanks (inputs) concerning the main patch and the ifodd patch. Can you please fill in the blanks?
I am sure that your problem is easy to solve but we should have the “missing parts”.
Maybe you can try to post it in a personal message to me (just click on my icon name and message me).

Best
K

Sorry about the blanks, and thanks for taking the time for all this!
The om-random and om= values in the ifodd patch are the same as those in the ifeven patch: 0 and 1 as the min and max for om-random, and 0 as the second input of om=.
In the main patch, the om-random values are 2 and 11, the om> is also 11, the second input of the om// is 12, and the second input of the om+ is 2. Let me know if any questions remain.

Dear theokoskoff,

Since i didn’t understand fully what you want, however i am sending you a beginning of a solution using of course omloop:

The termination clause of the iteration i didn’t get, so i have made an arbitrary 11 iteration on your process.

Here is the lambda patch following your description:

And here is a zipped folder to import in the workspace after unzipping:
iterations.zip (4.7 KB)

Please tell me if we are near what you want.

best
K

1 Like