< Back to IRCAM Forum

A simple iterative process with constraints

Hello All,
I am currently working through the basic OM tutorials and have a very basic question about how to go about creating an iterative process with constraints. If there is a tutorial available, please point me in it’s direction.

If not, what I trying to do is:

impose a rule on the augmented triad CEG# (or its inversion CG#E). As CEG# ascends, the G# can resolve either up or down a half-step.
If it resolves down, the next sequence would be GBD# (ascending) or GD#B (descending)
If it resolves up, the next sequence would be AC#F (or its inversion AFC#) and so on.
Just a chain of Aug. triads connected by half-step motion.
An example of a sequence rising which transposes CEG# up a few octaves (CEG# AC#F F#BbD D#GB CEG# etc.)

I’m hoping that I will be able to use OM to determine the number and contour of the sequences of triads will required to get from the initial CEG# to, say, GBD#.

Thank you!

Hi David,

I’ll translate your example to pitches in Z12 (C, C#, D, … , B —> 0, 1, 2, … , 11):

Up: (0 4 8) —> (1 5 9) (you’ve added 1 to every atom of (0 4 8) in Z12)
Down: (0 4 8) —> (3 7 11) (you’ve subtracted 1 from every atom of (0 4 8) in Z12)

What you request is quite straightforward to implement in OpenMusic once you translate it to pitches in Z12, I’m sure you’ll figure it out. Hint: check out Functions>MathTools>Groups.

All the best,

Hello António,
Thank you for your response! I will get to work.

Hello David,

as for a maybe different approach:
here is just a quick (and not too sophisticated) patch realizing the kind of concatenation you were sketching out via an iterative calculation.
Maybe you can go on from there.

Best Pre

asc desc.omp (11.7 KB)

… maybe a bit more sophisticated…

asc desc 2.omp (27.4 KB)

Thank you very much, Pre!

Hi Pre, Thank you again for creating the above patches! I’m just now becoming familiar enough with omloop to begin working with them. I have question about how I might alter the first patch you shared to produce the chord iterations in an arpeggiated form. I just figured out how to change the returned list via “flat” to a chord-seq (ie. a melody in quarter-notes), but is there a way to change the inner workings of omloop to produce a “flat” list?
Thank you!

asc desc.omp (11.7 KB)

Hi again,
Just one other question: If I wanted to make the asc/dec by a semi-tone random, how would I configure the sequence input of the omloop patch?
Thank you!

Patch 2.omp (13.4 KB)

Hi David, didn’t you give the solution already yourself?

  1. chords or arpeggio: change the list structure by removing the parenthesis with flat. (by the way: with a second input (shift- >) you can determine the depth of parenthesis-level to be affected - makes no sense here, but just in case). Also you can already flatten the result the loop gives at the finally output inside the omloop…
  2. random semi-tone up or down: I think you would need recursion instead of a loop as you need to reference to the random result at the very point of the repetition. That s a bit tricky. I will see if I find some time to puzzle that out…
    Best Pre
    qu2.omp (20.3 KB)

maybe like so?
(by using a solution once given by Anders…)

qu2.omp (23.8 KB) rand semitone.omp (5.9 KB)

Hello Pre,
Thank you again for your insight! Unfortunately, I’m still not familiar enough with lisp functions to have an “aha” moment. Looks like I need to keep studying… What sources would you recommend to explore lisp functions? I am primarily using the manual and tutorials on the OM page. Also, I have not been able to look at the recursion example patches you shared. The first box is dead, and I am unable to open the second.

Hi David,
the second patch is a recursive one, ie a patch witch is calling itself while/until a certain condition is true. It needs its arguments from outside, so it has to be placed on another patch. Maybe you put both patches on a workspace-folder. Like so:

(if the box is still dead, then left-click it and choose revive)

Concerning lisp, the OM-team gives some sources here:
You won’t learn it in a day, rather you will deepen your insight by puzzling things out.
A tour de force introduction for a kind of overview over the syntax you can have here:

A good glossary (maybe useful a bit later) is also:
among some more. You can find a lot via Google…

Good luck,

This “Simplified Common Lisp Reference” can also be a good pointer to start with:

I just recognise that I gave a wrong link to the lisp references given by the om-team. It should have been:


Thanks, Pre and Jean!