< Back to IRCAM Forum

Lisp first function doesn't gather (and outputs) correct value

Hello everyone, I have tried for the past 2 days to create a patch that allows me to generate a two note chord and obtain its inversion (top to bottom). I’ve realized that the problem lies in the “first” lisp function that doesn’t gather the correct value from the chord box. Up until that point, the list remains intact in its contained values. Funny thing though, is the fact that sometimes the inversion is indeed correct. I really can’t tell, there’s something that happens between the “chord” and the “first” objects. I’ll attach patch file. Thank you for your time.

rivolto.omp (8.0 KB)

Dear andreaslm

This is a common mistake. The problem here is that your om-random is evaluated twice, therefore, the inversion will be on a second evaluation of your random notes. To avoid that, you should put your CHORD object in eval-once mode:

The patch:

rivolto1.omp (8.3 KB)

see: OpenMusic Tutorials | OpenMusic

Best
K

1 Like

Thank you very much! Is there another way to make such a patch? Maybe more efficiently. I mean: I’d be fine with just knowing which objects can/should be used, then I will consult the documentation

You can code in common lisp. But your code is efficient enough in my opinion.
Again the reason to use eval-once mode is due to the random numbers evaluated twice

Best
K

1 Like

hey,

i dont know if this is more efficient, but here’s another way to achieve it. I removed the first chord from the chain but later i added it on the side in case one needs to see the result. Eval the sequence to obtain both chords simultaneously. As K said, very important is the eval-once thing. hope it helps.

best rc

2 Likes

Thank you both for your precious contribution! I’ll have a look at your patch @rc0 and will care to study it in depth, thank you