Forums > Gen

Archimedean spiral with gen~

February 17, 2013 | 8:10 am

heya,

I’ve been trying to wrap my head around gen~, and so far have had little success. Can someone post a gen~ patch that would create an Archimedean spiral in the audio signal realm? I have a feeling once I see how a basic expression like this is done in gen~, I’ll be able to move on to more elaborate ones. Thanks!

r(theta) = a+btheta


February 17, 2013 | 1:44 pm

If you can’t come to terms with gen~ in the time you have, poltocar~ is your friend (again!) Bit rough but should give you the idea. (And I still haven’t really grappled with gen~…yet…)

– Pasted Max Patch, click to expand. –

February 17, 2013 | 7:17 pm

Thanks, spectro. I know how to use the cartopol~ and poltocar~ objects somewhat, but I really want to get into using gen~ for doing complex expressions on audio signals, hence the request to learn from the gurus.


February 18, 2013 | 6:50 pm

Well you can duplicate what spectro posted inside of gen~ for similar results.

Whether the gen~ way is more efficient I do not know.

– Pasted Max Patch, click to expand. –

But I suspect you’re wanting to understand how to do this within an expr operator inside of gen~, is that right?


February 18, 2013 | 7:01 pm

Hi stringtapper,

Thanks, but yes you are right, my goal is to learn how to do complex math expressions inside of gen~, not just cabling a few math operators together. I am hoping someone will be able to demonstrate how to write this basic equation/expression with genExpr code. :)


February 18, 2013 | 7:09 pm

Can I ask if you know how to write the equation in the Max [expr] object (you seemed to indicate you might in your other thread)? If so I don’t think it’s going to be a lot different to do it in gen~’s expr operator, besides the obvious difference that it is operating on an audio signal.


February 18, 2013 | 7:15 pm

haha, that’s the rub. I don’t. I guess I am trying to learn gen expressions because I need everything to be done at signal rate, but I also need help with writing expressions in Max in general.


February 18, 2013 | 7:45 pm

Ha ok, then we are in the same boat. So it’s really about the issue of translating mathematical equations into code. For me the trouble starts with figuring out how to translate "theta" into something that the expr object recognizes. Understanding what "theta" even is in this context may be the real crux. That’s a mathematical deficiency on my part.

Sorry I’m not helping to answer, but maybe I can help better define the question so we may both get an answer. :-)

Now as far as there being a difference between connecting math operators together and simply using the expr operator in gen~ I am fairly certain it is explained in the Gen overview that there is no computational difference.


February 18, 2013 | 8:00 pm

the eventual goal: computing highly complex mathematical expressions on audio signals. I asked about creating an Archimedean spiral because it is a simple equation. If I’m not mistaken, In polar coordinates, theta represents the degree or angular coordinate. The r represents the amplitude, radius, or distance from the origin. The a variable should rotate the spiral (phase?) and b should affect the tightness of the spiral.

r*theta = a + b*theta


February 18, 2013 | 8:13 pm

"my goal is to learn how to do complex math expressions inside of gen~, not just cabling a few math operators together."

Unless you’re doing something that branches like crazy or is a billion lines long, I doubt you’re going to necessarily get a great deal of effciency by using the expr operator.


February 18, 2013 | 8:23 pm

I’m sure you are right, Gregory. I have no idea how complex I will eventually go, but for now, my interest may be more academic than practical.


February 19, 2013 | 1:09 pm

I took a look at http://en.wikipedia.org/wiki/Archimedean_spiral

The polar function is arranged to produce r for a given theta. We need a way to sample this function, e.g. generate a ramp of thetas from the output of a [phasor]. Converting r and theta to x and y just needs a [poltocar].

– Pasted Max Patch, click to expand. –

February 19, 2013 | 1:11 pm

For the broader goal, also check out some of the chaotic oscillator examples in the gen examples folder for more ideas.


February 19, 2013 | 2:53 pm

I’ve never used codebox but it turns out it’s very very easy! 5 mins with the GenExpr help doc and I got this:

– Pasted Max Patch, click to expand. –

February 19, 2013 | 3:03 pm

and here’s Graham’s last example (sexy BTW) CodeBoxed.

– Pasted Max Patch, click to expand. –

February 21, 2013 | 9:42 am

thanks Graham and leafcutter. I haven’t had time to really dig in to your patches, but I will soon…


February 21, 2013 | 12:07 pm

@leafcutter: and instead of the actual values, it is possible to write twopi and pi.


February 21, 2013 | 12:11 pm

jvkr – I think we both did use pi?


February 21, 2013 | 12:17 pm

When I open your before last patch it says this:

sigA = in1 * 50 – 25;
sigB = in2 * 6.28318 – 3.14159;
out1, out2 = poltocar (sigA, sigB);

And indeed, that latter uses pi—didn’t see that :)


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