Mathematics and MAX/MSP
Hi. I'm new fairly new to MAX/MSP and I've been playing around with it quite a bit lately. I'm really interested in generative music and would like to apply some complicated dynamical systems and algorithms to some patches. What is the best way to go about this? Should I stay within MAX, (I feel like its mathematically limited in some ways)? Could and should I integrate C++ or Java Code into MAX? Whats the best way to tackle this? I know a bit of C++ its been awhile since I've used it though. Thanks!
I don't think max is that mathematically limited...
On 23 sept. 08, at 16:29, Nathan wrote:
> Hi. I'm new fairly new to MAX/MSP and I've been playing around with
> it quite a bit lately. I'm really interested in generative music and
> would like to apply some complicated dynamical systems and
> algorithms to some patches. What is the best way to go about this?
> Should I stay within MAX, (I feel like its mathematically limited in
> some ways)? Could and should I integrate C++ or Java Code into MAX?
> Whats the best way to tackle this? I know a bit of C++ its been
> awhile since I've used it though. Thanks!
[expr] can do a lot, [vexpr] for lists, [jit.op] / [jit.expr] for
matrices. And if that's not enough you can do some math inside Max
using, JavaScript, Java or C.
ej
Cool. Yeah I haven't really probed deep into MAX's mathematical structure. I'd like to do some things with Automata over Algebraic Cyclic Fields, L Systems and the like. I know things like Markov Chains can be done with ease in MAX. Some stuff with the automata becomes computationally intense and often deals with large matrices, I didn't know how MAX handles these things.
How is C used inside MAX?
C is everywhere: any max object is written in C. If you want to use
markov chain, have a look to the prob object.
ej
On 23 sept. 08, at 18:33, Nathan wrote:
>
> Cool. Yeah I haven't really probed deep into MAX's mathematical
> structure. I'd like to do some things with Automata over Algebraic
> Cyclic Fields, L Systems and the like. I know things like Markov
> Chains can be done with ease in MAX. Some stuff with the automata
> becomes computationally intense and often deals with large matrices,
> I didn't know how MAX handles these things.
>
> How is C used inside MAX?
Lots of people use code-based elements for the things that code can do more easily than the standard Max objects. Really is a matter of taste in many instances (could do things either way), though there certainly are some things it can do more easily. .js is quite straightforward to implement, if you've got skills in that area...probably most of the math stuff is straightforward to translate into it.
As mentioned, there's a wealth of functions already available, like the expr and jit.expr, vexpr, and table functions (calculating on the whole table set without needing to do for loops to iterate). I've only needed code elements a couple of times, since I try to figure out how to do things graphically first, and have *usually* been successful, but at times it would have been better to go with code from the start. As you create new ideas and challenges, it's often a learning experience deciding which route (or what mixture of both) will be best, and of course, this is often not known without experimenting quite a bit.
My advice is to use Max's graphical elements and objects for their strengths and use bits of code for pieces that are giving you trouble with implementation. For things like UI, automation, presets and interpolation (pattr), controller input, etc., Max is really straightforward and powerful. You can then take these numbers as parameters to more complicated functions, some of which will be easy to create in Max and some you might want to write in code. (Having them in Max means more immediate results, but an open .js file that you tweak and re-save isn't bad.)
Using numbers generated in this way relieves you from having to manage tons of abstract variables in your code---the snippets just take numbers in (labeled, for example, param1, scale1, xposition, or whatever you plan to do with them)---and perform the desired calculations---in such a setup, all variables in the script are local and it's just a "black box" with a set of named functions.
Seeing all the possibilities of a particular function is really simple in this way---like easily being able to try all possible parameter numbers for a function (say 1-1000) at a settable rate? Metro-->counter-->function, at whatever speed you want, or in either direction. Or trying patterns of values? Counter-->table-->function. Use things like preset on tables to store banks of whole-table settings, then flip through them to see what happens. Lots of possibilities there, and with the ease of hooking things up (data, functions, and logic) you'll come up with all kinds of new ideas for interaction and experimentation which could be quite laborious to create using only code.
Also definitely check out jit.bfg if you're into mathematical patterns, I've used that to great effect for generating interesting flowing patterns to run LEDs, create textures, and morph GL vertices, among other things. It's a really interesting way to get a lot of appealing generated patterns of data without a lot of work, and there's a bunch of useful parameters you can apply. After you get your pattern/matrix out, you can then apply some of the jitter effects on top of it.
Dig in! Maybe the best way for you to experiment is to keep in mind "how you'd do it in code", if you're more familiar with that. This *could* be a good structure to fit the new techniques in. However, keep in mind that the underlying methods for getting things done are rather different than code (as you're probably aware), so you need to understand the differences to be most effective. Hopefully you'll quickly get a feel for where the strengths of each lie. I do know that if you like math, and you want to experiment with mathematical ideas, you'll definitely like Max.
--CJ
Quote: seejayjames wrote on Tue, 23 September 2008 11:23
----------------------------------------------------
> Also definitely check out jit.bfg if you're into mathematical patterns, I've used that to great effect for generating interesting flowing patterns to run LEDs, create textures, and morph GL vertices, among other things. It's a really interesting way to get a lot of appealing generated patterns of data without a lot of work, and there's a bunch of useful parameters you can apply. After you get your pattern/matrix out, you can then apply some of the jitter effects on top of it.
----------------------------------------------------
Hey CJ, jit.bfg is pretty cool! I had no idea that it even existed.
So let's say that I have a pattern that I think is interesting.
How do I access those values and map them to musical parameters?
I am not very familiar with jitter. Would I just step through each
pixel? Also are there other similar jitter objects that one
could use to generate control data?
A pretty big question, but a simple place to start is jit.spill on the resulting jit.bfg matrix. Hook that to a multislider and you can see the lists generated in one dimension (if the jit.bfg is only one plane, that is, luminosity-only per pixel). Nice to insert a jit.op * (from 0. to 1.) after the bfg but before the spill, to be able to scale the overall levels of each pixel. (Possibly this is better computationally than a vexpr on the resulting list? Same idea, as I understand it.)
You can always do a getcell for individual values too, but I like seeing them in multislider. Even a low-res bfg (like 16x2) will generate (under your parameter control) 32 shifting values, then use *as controls*. I like mapping these to things like volume and frequency of cycle~ etc., filter settings, delay levels...well, you get the picture. Good parameters for bfg include scale, resolution, and offset... use a counter to move the offset and you'll get an overall "motion" of the values in whatever direction you want... very effective. I did this with a pictslider for x and y control, it was a little tricky to get the parameters right (some needed to be negative when I thought positive), but once I had it I used it all the time: smoothly moving fadey colors of a large LED installation at Burning Man, hours of nice ambience. I also used a joystick's two thumb controllers for it: one--> hue/brightness, one-->fade time and overall speed. These took some more work, but the objects were jit.scalebias, jit.xfade (back into itself thru a speedlim, great trick for video too), and the offset speed to jit.bfg.
Having a nicely-tuned oscbank~ whose volume levels get affected by this shifting set of values sounds awesome. You could also get great mileage out of applying a subset (say 8 or so) as a constantly-shifting EQ setting on samples. If there are certain "snapshots" of the bfg you like, use jit.matrixset to store them, or (perhaps better yet) a pattr on the resulting multislider list. Then you can morph between as many stored list settings as you want, without the bfg running, and without creating the lists with the mouse.
Definitely look into the Jitter objects, there's a ton for video (obviously) but there are some more esoteric gems like this one hiding in there, plus all the creative ways you can combine them.
--CJ
Go the Max way.
When/if you find the limit, post the (precise) question on this list.
The good thing with Max is that all the interface with audio world (MIDI,
audio...) is available to you. You don't want to program that in C++.
J-F.
--
http://www.jeanfrancoischarles.com
>
> Hi. I'm new fairly new to MAX/MSP and I've been playing around with it quite a
> bit lately. I'm really interested in generative music and would like to apply
> some complicated dynamical systems and algorithms to some patches. What is the
> best way to go about this? Should I stay within MAX, (I feel like its
> mathematically limited in some ways)? Could and should I integrate C++ or Java
> Code into MAX? Whats the best way to tackle this? I know a bit of C++ its been
> awhile since I've used it though. Thanks!
Quote: jeanfrancois.charles wrote on Wed, 24 September 2008 15:51
----------------------------------------------------
> Go the Max way.
> When/if you find the limit, post the (precise) question on this list.
+1
If you are new to Max, it is probably best to _try to do _everything in "native" Max first. This includes objects like [expr], [vexpr], [if] and such which allow you to evaluate c like expressions. This way you'll learn the basics, the possibilities _and the limitations of the program/language quickly and thoroughly.
If you are not sure how to do this or that, post to the list. You'll quickly see that A LOT is possible with vanilla Max.
The only external library you should probably get relatively soon is the Lobjects collection for dealing with lists, although in max 4 the native list tool "zl" is extended too, so it might be less necessary.
Then, after a few (2-6) months, if you still feel the need, start integrating some java(script), or develop your own externals in c using the SDK.
Good luck, enjoy the ride :)
Klaas-Jan
Here is what I was able to whip up. I must say, jit.bfg is amazing. I think I will get a lot of mileage out of it.
Yet Another Plug for maxlispj today -- if you want to do some serious
mathematics, you can apparently run Maxima in maxlispj:
On Sep 23, 2008, at 10:29 AM, Nathan wrote:
>
> Hi. I'm new fairly new to MAX/MSP and I've been playing around with
> it quite a bit lately. I'm really interested in generative music and
> would like to apply some complicated dynamical systems and
> algorithms to some patches. What is the best way to go about this?
> Should I stay within MAX, (I feel like its mathematically limited in
> some ways)? Could and should I integrate C++ or Java Code into MAX?
> Whats the best way to tackle this? I know a bit of C++ its been
> awhile since I've used it though. Thanks!
Hey Brad, is there a good LISP editor/environment out there
that would help in developing LISP code that I could
load in maxlispj?
OK so I took the jit.bfg a ways further. Check it out:
--dimension controls (2 to 256)
--automatic movement using XY and a scale
--stripped out the controls and function types that didn't really do much (don't understand why, for most of them :)
--normal and inverted weights
--controllable fade, biggest effect towards maximum values (try on video too!)
--record/play back/save every control you change with the good ol' mtr object
Hopefully this will provide a lot more ideas. I especially like the motion control, this frees you up to tweak other things...
have fun!
CJ
don't use jitter (yet) but am admiring your patch with ignorance and awe, seeyajames. though - why not use presentation rather than lock/unlock?
ps - never knew about the mtr object. quite awesome, thanks for showing me that.
thanks!!
I never have gotten used to the shift back and forth with presentation mode, so I still patch like 4.6. I like to have things stay where I leave them. Still, probably should get on that... there's good reasons for it :) maybe my brain can't keep track of dual placements of objects, I dunno. Probably I'll just practice encapsulating more... tho there's pros and cons with that too. ack!
yep, mtr is pretty awesome. I use it all the time!
--CJ
Quote: Nebula wrote on Tue, 23 September 2008 09:33
----------------------------------------------------
> Cool. Yeah I haven't really probed deep into MAX's mathematical structure. I'd like to do some things with Automata over Algebraic Cyclic Fields, L Systems and the like. I know things like Markov Chains can be done with ease in MAX. Some stuff with the automata becomes computationally intense and often deals with large matrices, I didn't know how MAX handles these things.
>
For L-systems, automata, and large matrix processing you should definitely look into the Jitter objects.
The suggestions to start out doing everything in Max is good advice. It will certainly ramp up your Max skills pretty quickly. If you do use other programming languages in the future, chances are you will want them to interact with your Max patches so you will need those skills.
Depending on your background, if you are comfortable with text programming languages, many algorithms are more easily expressed in standard code than in a Max patch. When things start to get really complex, I definitely can work best in an object oriented language like Java or Ruby, so I tend to use those in conjunction with Max a lot. And most programming languages have comprehensive libraries for all kinds of things (like mathematics algorithms, see Brad's post on the LISP stuff). The important thing is to find the tools you like the best, learn their strengths and weaknesses, and figure out how to make them work together. Then a whole new world of possibilities will be open to you.
If you are interested in Java, this might help get you started:
http://compusition.com/web/articles/maxmsp-eclipse
For C, I believe if you download the Max SDK (check the downloads pages) there's some instructions in there to get you started on developing your own Max objects.
But spend some time with Max first! It will be worth the effort.
Seejay James schrieb:
> I never have gotten used to the shift back and forth with
> presentation mode, so I still patch like 4.6.
Its even better then unlocking/locking, just open a second view of the
same patch, while you patch you see what changes in presentation...
(no need to shift at all...)
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com