< Back to IRCAM Forum

Beginners question - loop recursion

This is an absolute beginners question and points out my misconception about recursion…
I built a loop, which tests if a midinote is in a certain range. The “good” range is between 3600 and 8400. If the note is smaller then 3600, it adds 1200 and if the note is higher then 8400, it subtracts 1200. This loop works fine so far.
But I have to make it recursive somehow, because if the note is very small like 1000 it adds 1200, which results in 2200. Which is still out of the “good” range. So i have to do the loop a second and a third time to fit it in the right range.
Could you give me a hint?

I attatched the omp and 2 screenshots.

rangeLoop.png

Hi Bensi,

There are two ways to do recursion in OM the first is in the patch below.
The second way is in the patches 38 & 39 of the OM Tutorial with comes with the basic OM workspace.

Have a good patching.

Jean-Michel Darrémont

fonction-recursive.omp (3.74 KB)

Dear BEnsi

Here is what maybe you’re looking for. It’s not recursive but works good for me.

BEst
K

registrator.omp (19.1 KB)

First of all, thank you for helping me.

Unfortunately, I couldn’t open registrator:
OM > Error while checking /Users/blabla/Desktop/registrator.omp: The variable <!doctype is unbound.
OM > File /Users/blabla/Desktop/registrator.omp is not a valid OM document

But I have found a function OCT-TRANS in the OMTristan library which does exactly what I want. It brings values in a certain range by octaving.

But before I found this function, i tried to work it out by myself. I made several attempts to stop the recursion loop, which worked out, but the last results were not, what i expected. One of them i like to show you.

I used MAPCAR to do the successive calculations. I would expect, the result of MAPCAR is a list. Which seems correct, but the very last result, which is returned is not a list, but the first element of a list. And I don´t know why?!? (I did a cumbersome action by comparing the lenght of the lists with X-INTERSECT to stop the recursion, but it worked.)
Maybe you can overlook the patch briefly.

range-loop4b.png

ok
here is registrator
Sorry the attachment apparently is not valid due to a major bug in forumnet !

registrator.omp (19.1 KB)

Hello,

although with frequencies, I had the same problem. I (think I) solved it with recursive green patches in a loop.
I attach the screenshot.
Looks like working - or am I missing something?

Thanks!

Marco

loop_check_range.png