Why Do I Get Stack Overflow When I Have A Condition That Is Guaranteed to Solve Itself?

ComfortableInClouds's icon

I am trying to build a midi note range limiter, but get a senseless stack overflow message. Here is what my patcher logic looks like:

Max Patch
Copy patch and select New From Clipboard in Max.

now, if you remove the patchcord running from the [+12] object back to the [ < ] object, it runs fine. See, eventually the patch will solve itself, because if you add 12 enough times, you'll eventually get a value higher than what's given as the bottom note value. Why then will Max not allow this?

Gregory Taylor's icon

There's no way for a patch to "know"
that it will solve itself.

Perhaps another look at the paragraph
"The Trouble With Loops" in Max Tutorial
5 might help to refresh your memory as to
why loops are bad things.

Gregory Taylor's icon

You might also benefit from the split object.

pure's icon

or zmap?

Gregory Taylor wrote:
> You might also benefit from the split object.
> --
> knowledge is not enough/science is not enough/Love is dreaming this equation
>
>
>

Peter Castine's icon

Note that Max has a finite amount of memory to work with.

If your patch has a feedback loop, Max (or any program) has basically two options: (1) interrupt processing before the stack overwrites some other area of memory or (2) crash.

By and large, the former of the two options is considered preferable.

There are a zillion other ways to implement what you're trying to do without eating up ridiculous amounts of memory.