Forums > MaxMSP

mandelbrot musing

April 28, 2011 | 11:31 am

Hey

In the long term I’ll eventually be looking at using Mandelbrot/Julia sets in order to generate sound and synthesis but as a starting block and a general maths/max/programming muse I’m looking at how I can efficiently generate the set using Max objects…

I have a skeleton patch which performs a single iteration but the problem is in the feedback – the inevitable stack overflow that occurs when running stupid calculations with infinite feedback loops even when you have breakout conditions e.g. z>4 or n>100. I know I can use triggers and timing to solve the problem but in my eyes that defeats the point – I’d still like to run the routine waaay into ‘the red’ so to speak such that I can generate high resolution sets in the fastest allowable time…

Any thoughts?


April 28, 2011 | 12:06 pm

Hard to say without seeing your patch…

Anyway, you get stack overflow if you feed your result back in a "hot" inlet. A strategy to avoid this can be to feed it in a "cold" inlet, and having an Uzi set to a large enough number triggering your computations one after another. The drawback of this solution is that you can’t interrupt the shooting, and this can be quite time-consuming. But the point is, there is no such thing as easy-to-control iterations in Max.

A possible (although somewhat cumbersome) alternative is to use bach.iter with a long enough input list, instead of Uzi. bach lists can have virtually unlimited length, and bach.iter allows to stop the iteration "on the fly" – if you’re curious, give a look at http://www.bachproject.net

But the truth is, the best you can do is writing some code – I’d say that, given the nature of the problem, even some JavaScript would give you better results than a patch. And if you feel like leaping to Java or C the results will be amazing, I promise!

good luck
aa


April 29, 2011 | 1:22 am

I second that, I worked for a couple hours to make a prime factorization patch in Max, it works fine, but due to the iteration, at high enough numbers I get stack overflows. (Was pretty smooth up until 600000!)

I have a teensy javascript instead, which has never failed me, and lets me create factorizations and put them into a text file at 100 numbers per second, no problem. Wish I could do that in my head. Or maybe not…

Anyway, the advice is good, there are certain things you just don’t want to iterate (recursively) at certain speeds in max.


April 29, 2011 | 3:31 am

Thank you so much for your post.

__________________
watch movies online free


April 29, 2011 | 11:39 am

Writing in C or Java would be a more elegent solution – writing objects in code is something I never covered at uni mind and have no notes about how to go about it… Guess I’ll have to do some research!!


April 29, 2011 | 1:04 pm

Really, try with JavaScript first. It’s slow, but easier than Java and waaaay easier than C – and, once you’ve grasped the concepts, switching to another language will be relatively straightforward. There are some JavaScript tutorials in the Max doc to get you started, and tons of info around the net. You’ll see that a basic implementation of a Mandelbrot calculator is quite simple to code.

have fun!!!
aa


April 29, 2011 | 1:17 pm

Oh I have some experience in C, but never looked at Java. And I’ve coded a neat looking set in AS2 recently. I tried using [flashserver] to link my AS2 code with Max but it was pretty lethargic – wasn’t running anywhere near as quick as I would’ve liked.

Likesay I think I just need to look up how to write Max objects in C :)


April 29, 2011 | 6:29 pm

AS2 and javascript should be pretty close, except for the Flash-specific methods of course.

Plenty of code samples online for making cool sets, you can adapt to js pretty easily. w3schools.com is great for all things web, and has a large section on js as well.

For a fun fractal overview, check this out…oh yeah!

http://en.wikipedia.org/wiki/List_of_fractals_by_Hausdorff_dimension


April 30, 2011 | 11:21 am

Wicked – starting to get to grips with the javascripting – as helpful as the java tutorials are they talk little of handling multiple inlets but I got there in the end… Hopefully I’ll have some max fractalness to post soon!

Nice one for the advice guys


Viewing 9 posts - 1 through 9 (of 9 total)