XML Feeds

.

[maxmsp] Advice with maintaining state / data structs

Adam nanoarchae at gmail.com
Thu Oct 18 17:55:18 MDT 2007


Hello! Newbie to Max here.

So I'm implementing a patch that's meant to accept a command string via a message, parse the arguments, and then send a series of messages to a play~ object.

For example, the initial message might look something like "snare 100 200 127 255 3" meaning the 'snare' buffer~ should be played for 200 ms, starting at 100 ms into the buffer, starting at half volume (127) and ending at full volume (255), and this should loop 3 times. Actually, I've already managed to get that type of thing working, but what I'm implementing involves a lot more variables and dynamics. This is still the basis however. The point is that I have a lot of looping, changing variables, math operations, and order-important evaluation going on in my current method (which is some byzantine mess of cords) and it's increasingly difficult to understand, modify, et c.

My question is: is there a conventional way to maintain state and variables in Max? My background is in textual programming languages, and I can't help but to think in terms of for loops, while loops, conditionals statements, small math operations, all of which I have been able to emulate in Max individually, but when I go to implement these seemingly simple algorithms, I end up with these giant confusing cord orgies, totally inelegant, constantly worrying about what is going to get evaluated first, and I'm often unable to figure out what I even did the previous day.

Is there any sort of object that I can use to get, set, compare, and manipulate variables via messages? This post is getting lengthy and tangential, but I envision something that I can send a message to like "x = 5" to assign a value to x, or "x = x + 1" or any other math operation, or "get x" which would send the value of x through its outlet, or "clear" which would clear the symbol table, et c. Does anything like that exist? Are there any other methods commonly used?

Any tips are much appreciated. Thank you in advance!


More information about the maxmsp mailing list