Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 1 hour, 27 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Circular lists

Author 2 Subscribed Users |
fiboribo
fiboribo

Hello again from Miami,

Is there a way to rotate through elements of a list in a circular way with each evaluation? For example given 6000 as the starting pitch I would like to add the values (100 100 300) circularly until the maximum register of a particular instrument is reached.

I obtained the result I was looking for (see attachment) using repeat-n for the list of intervals and then removing anything higher than a certain pitch using “remove.” But now I am curious to know if I could rotate through a list indefinitely, not just (as normally in OMloop) until the last element is reached. It might be useful sometime.

Thanks!

Federico

 

Attachments:
  1. scale

    scale.png

May 19, 2013 at 23:13 #4860
Profile photo of Karim
Karim

Dear Frederico,

I don’t know if this is what you want exactly. But the annoying thing in your patch is exactly the repeat-n.. Since the algorithm is not supposed to know that you should repeat your sequence of intervals n-times.

So you need indeed  to use the loop macro (omloop) using while (c.f attached patch).

Best

K

 

May 20, 2013 at 02:01 #4862
fiboribo
fiboribo

Dear Karim,

Thank you very much for your prompt reply. I agree with you. The reason I was asking was exactly that it didn’t seem necessary to use repeat-n without first knowing how many notes the scale would need. I do have one question about your patch: If I understand it correctly, it builds a new scale fragment adding (100 100 200) via dx->x as long as the last note of the scale fragment is lower than 9500. That means that all of the three intervals will be added at each iteration.

My initial idea was to do the following: Given 6000 as a starting pitch and (100 100 200) as my dx intervals, at each iteration add the first interval only, then the second, the third, the first, second etc. while each time checking the result and comparing it to 9500. So the scale might end with the addition of say interval no. 1 (100) or 2, and not necessarily 3.

I hope this makes sense. I suspect that the underlying issue is that my knowledge of Lisp is way too basic. That could be one of my summer projects… :-)

Thanks,

Federico

May 21, 2013 at 02:52 #4866
Profile photo of Karim
Karim

Dear Frederico,

 

Yes it makes sense. You can after the loop filter out the range. But also make another more complicated iterattive loop.Best

K

May 21, 2013 at 17:51 #4869

You must be logged in to reply to this topic.

Log in now