Beta Gen Documentation
hello everyone. This information will be included with the next release, but until then here is some beta documentation describing the new Gen technology. Any feedback is appreciated, particularly if there are subjects that could use more detail or are missing, confusing terminology or descriptions, …
Here’s the link:
Jumping the gun a bit, but will there be an SDK for [gen~] operators at any point? That would really be the icing on the cake.
An SDK is something we are hoping for a future release (no promises although I really want to see it too). I will say it won’t be in a 6.0 release though.
Excellent document – like many others I am very enthusiastic about gen and its Jitter cousins. A few questions:
– GenExpr language: in the case of only being interested in one return value from an expression, the document describes the case where you assign the first return value to a variable but discard the second. Is there a way to reverse this – to discard the first return value and assign the second?
– is the namespace in codebox global – i.e. if I define a function in one codebox can it be called in another?
– is it possible to add the equivalent of the history operator in a jit.gen or (more importantly) jit.gl.gen context? This would be an extremely elegant way to allow for feedback processes, but I don’t know if it’s feasible. As FBO’s are not readable in GLSL I’d imagine the answer is no, but worth asking.
"- GenExpr language: in the case of only being interested in one return value from an expression, the document describes the case where you assign the first return value to a variable but discard the second. Is there a way to reverse this – to discard the first return value and assign the second?"
// the Gen compiler does dead code elimination, so the variable "notused" won’t actually be used
notused, myvar = cartopol(in1, in2);
out1 = myvar;
"- is the namespace in codebox global – i.e. if I define a function in one codebox can it be called in another?"
not currently. We will support some kind of import message in the near near future that will load in files of
"- is it possible to add the equivalent of the history operator in a jit.gen or (more importantly) jit.gl.gen context? This would be an extremely elegant way to allow for feedback processes, but I don’t know if it’s feasible. As FBO’s are not readable in GLSL I’d imagine the answer is no, but worth asking."
No. None of the Gen objects support this operator. As you can imagine, for the history operator, we’d have to create a temporary buffer the size of the input matrix for this to work. While technically feasible in jit.gen and jit.pix, it’s not at all possible in jit.gl.pix. Since the jitter Gen objects don’t suffer from the "single sample" delay problem that MSP objects do in feedback situations, I don’t think it’s much of a burden to require feedback jitter Gen patchers require the user to loop the output back to a second input.
> Here's the link:
Most pictures in the first pages of the document are incorrectly displayed in Adobe Reader (8.1.1) (but are OK in MacOS X's Preview app).
Thanks Wesley – all confirming what I had guessed. It’s good to hear that you will support function import at some point in the future.
Thanks Roald. I’m seeing the same in Acrobat Pro. Really odd! Looks like the print to PDF function munged some things up.
Really useful document, thanks! I’ve been muddling along with gen~ for the last few days but this makes things much clearer.
A small question – is it possible to use the history operator within a codebox? It currently throws up an error, so I’m guessing it’s not allowed. That’s a shame if so. It’d be a great way to easily implement more unwieldy filters.
In the beta, we didn’t get to implementing History in a codebox, but for the release this is already in there. The syntax will like this:
y = x + 1; // fwd use of x
x = history(y * 2);
out = y;
note that x is used before it’s assigned to. This will _only_ be allowed for feedback operations and we enforce that strictly. Anything else will throw errors.
Ok, that’s great to hear! Looking forward to the release version!
Because you asked for comments…
I think it will be very helpful if the docs would answer the following:
1. What are the intended usages? This would need to be supported by examples showing some contrasting implementations as working and commented patches.
2. What are the performance (or other) gains? This would need to be supported by evidence in the form or working and commented patches showing parallel performance with contrasting setups (gen/not gen). It would also be good to have similar working patches highlighting the areas of applications where the advantages can be greatest. And some text explaining where the advantages are unlikely.
Hope you agree. Thanks.
despite the fact I understand that gen is supposed to be used for more versed users in programming, which is not my case, I would really appreciate to have the use of gen made more clear for a broader audience. I intend to put my efforts on learning how to use gen and the suggestions from jhdkfj39929 sounds very interesting in helping on it.
hi sandroid. Gen is a lower-level patching environment, but our goal is certainly not to limit it to a certain level of user. It should be accessible to everyone. If you have any other ideas or comments about what is/isn’t accessible in terms of how Gen is presented in the documentation, please post them here. thanks!
thanks wesley and Joshua. I start grasping the reason for really put myself into gen.
I am looking forward for the examples Joshua mentioned in his post. I think they could help "lastminute programmers" like me, who have never programmed anything before getting in touch with max. Related to this, which directions you could point me as a initial ground to start with? in other words: should I get acquainted with languages like C, C++, Java, or even OpenGL, shaders programming before going into gen or gen some how will be self-explanatory. will I need some background on program paradigms (how to organize the program in variables, functions, etc.)?
In general terms, how can somebody who has learned programming from a graphical oriented environment (and its data flow paradigm) be able to grasp this low level programming? I suspect this question goes far being the scope of this forum. But maybe I am wrong…
Anyways, things are getting really exciting with max6 (I have been patching with Jitter – my main interest- last days,and I am very excited with the new possibilities). Somehow I can recover the same thrilling feeling I had in the first time I saw and played with Max in 2001.
This is a good question. You shouldn’t require any special programming knowledge to get started with Gen. In many instances, you will probably find Gen to be very similar to patching in a standard Max patch. I would recommend looking through the included Gen examples and trying to do a little patching yourself to get a better idea. Like anything, it will take some time to get acquainted with all the features and workflow, but if you are already familiar with Max and Jitter, a lot of that knowledge will translate. My advice would be (like learning Max) to start small and try building some simple things, and scale up as you get more confident.
Can we have loops in codebox pls?
Also, no arrays, why are there no arrays? I want to be able to make arrays of history etc…
@veqtor For arrays, I believe you can use data with peek and poke for now. Loops will be coming eventually.
@sandriod Just wanted to reiterate what Andrew said. There’s no need to know C or GLSL to start using gen. If you start using codebox, the expression syntax is very simple and if you study any text programming language like JS, Java, GLSL, etc. many of the ideas should translate.
Some simple synthetic benchmark examples in the other thread:
Thank you. Very helpful. I look forward to more examples. Generally, while MAX documentation and tutorials are very good, I feel one type of storytelling is not very well represented. And this is showing/evidencing via completed projects of some sophistication and of immediate aesthetic value (witness Epic Games trying to impress with the demos like Samaritan – cheesy, yes – but advanced).
(Perhaps I should disclose that I am more interested in Jitter and that the audio side of things might be much more mature – I cannot judge.)
Take for example the available tutorials for drawing or shading in MAX 5 (Tutorials 40 and 41). Or, in fact for most of visual processing. They present some(many) option and demonstrate some working setups but the demonstrations are not intended to be visually convincing. In fact, the functionality they show is basic and the outcomes are ubiquitous to many other systems. So, it is hard for students (or even expert users working outside of their typical specialization) to appreciate what is possible or visualize the path from idea to implementation. Or to appreciate the unique strengths (or even weaknesses – being open about them would make the strength that much more convincing) of MAX as the development environment. With many other complex development/design environments, the task of producing such examples is taken up by 3rd parties. Witness Gnomon tutorials for Maya or cmiVFX tutorials for Hounidi (e.g., the one on Procedural Cities), etc., etc. For MAX, such materials are not that readily available.
I am not sure how one can go about it. Maybe people could suggest some interesting/relevant projects that could be build and exhaustively explained by the Cycling people? Or one could commission some expert users to share/annotate their projects for incorporation into tutorials?
If one could see something immediately impressive and have it explained/available for tweaking, the MAX environment would be that much more appealing. The experience of teaching MAX alongside Processing, for example, shows how the availability of many complete and working examples (e.g., via OpenProcessing) is immediately appealing to the students (and educational to all).
Returning to Gen. Apart from seeing what small-grain gains should be possible, I would love to have access to some examples of more complex projects as discussed above. For example: can one build a fast, large-population, multi-threaded agent system using Gen? Can another version of this system be run on GPU, using Gen? Can the new MAX physics be added to it?
Or what can the others suggest?
@jhdkfj39929 Thanks for your feedback. Great points.
We’ll be continuing to work on documentation and examples. Right now we’re focusing pretty heavily on just getting the software done, but over the next several months we’ll be fleshing out with some of the things you mention.
In the meantime I’d suggest you examine the Projects, Toolbox, Article, and Interview web pages where the type of content you are referring to are more likely to exist than the in application tutorials which are designed to simply communicate functionality. We hope to make it easier for users to share large projects and tutorials (almost all of your mentioned examples above come not from the package developers but the community of users).
Regarding Jitter performance, the use of jit.gl.pix is even faster over CPU jitter objects than any of the gains you’ll witness in MSP. We’ll have more illustrative examples soon, but it’s equally mature to the gen~ audio work. Not many examples however.
Regarding your specific questions:
> can one build a fast, large-population, multi-threaded agent system using Gen?
Yes. Simple example in:
> Can another version of this system be run on GPU, using Gen?
> Can the new MAX physics be added to it?
Not to the gen code itself. The code compiled in Gen cannot interface with outside code. The data can move in and out, and one could build something which ties these different parts together in various ways.
Okay, I’ve got to spend more time developing the software than explaining these things right now, but once we release, I’ll get back to helping explain and answer some of these requests.
Good documentation is a real help, and the Max tradition of help files for everything is really useful.
I think the fastest way for me to really get something is through tutorials, and I hope there will be some gen~ tutorials soon. Tutorials offer a glimpse into someone’s process and reasoning and this really help with the challenge of building from scratch.
Thanks again. Yes, a more sustained community effort would be good too. Still, things like Processing are free and this is encouraging a sharing culture where whole projects change hands and books with examples follow multi-project themes (cf. The Nature of Code, now that i mentioned agents). In the other communities I mentioned, people pay for tutorials. With MAX neither mode has quite taken off so it seems reasonable that the developers chip in.
"> Can another version of this system be run on GPU, using Gen?
Not nice to tease people…
Sorry. Not trying to tease. Just limited time for forums at the moment.
The caveat is that you have to treat your data as pixels currently, and then what do you do with the data to render? Right now you would then need to move the values back to the CPU. There are lots of creative ways to use jit.gl.pix for gpgpu programming.
In the future, we could have an OpenCL backend for other kinds of data types than vec4 on gpu, and other possible utilities.
thanks Joshua and Andrew for the feedback. I will start small… :)))
looking forward for more examples on how to handle Gen for Jitter (among some other really cool new objects, like Jit.gl.camera, and the improvements in the jit.gl.model).
thanks a lot for this great upgrade in max.
We’ll be able to roll out a lot more example and tutorial content for Gen post-release. I know I personally am looking forward to making some "Gen Recipes" when I can get a chance. For now, here is something I whipped up the other day using jit.gl.pix. More soon, hopefully.
----------begin_max5_patcher---------- 2163.3oc4bt9iaaiD.+yd+qf039TyZWQR8xGNbnKvcsn.sIGZRANbEAKnkn8 xD85jjS11h9+9wGx1RY8CJRGGo8PLj2PIQM5Gmgblgj9OtYxzk4ORqlB9qfe ELYxebyjIxhDELo4+OYZJ4wnDRk7xlFkmlRypmdq5b0zGqkk+lGXU.9GRFf9 HIsHgBxWA1TwxVC9dZFnNGvu0krLJfv+qMMWvRREKBvRIqofhx7HZUEkWOY7 Km.D2L+xpdfDSKmu8QlvqCdEjIettMElsIkkkPqkBIrovBRczC7539RZTs5k zMHbtys.Tni3KXf7KezbGva2WS4ap2VUNMkxhkuk4Ke2LX3VIYUdVcFIkJO0 ckLRxtyTtdo5AJe.6O.a8jD2dE62k2NjKBhR+yatQb3VKaMVQowKIQumi3UU z5ChNTOQm2hEh2fE9RjEHNhc6E37GQf62yySuHXy0IvRr4M7wVLa0JZIMKhB R2jTyJRXzxKB9vViO2gO9pH0aJI0r7ro8DOHnznDBUcjgkct4zK9fG974uMa 1lJpXrENTDCgTkPVBVkWB1Zu1atg8ZMN.xwq+fawvma4EpQdqnzYy968kQBg YGhBC6OgFPcbsJImKt8k.9Hk0EVJRdNmAAnmh.W34YPAojWdMs7dZFYYBsMM U0d8uUPURj3EgvanASWRxVO8RhnL5G4R7SzgJHuGHkvFeI3MO7OGjjtmv4Aj TYB5o.Jx+LnDd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lG.4ed y+C.8Y4rL -----------end_max5_patcher-----------
Hi, does anyone how to use the "for" operator in codebox, and in general whether it is possible to use in jit.gen cycles?
And yet, as you can take submatrix of the matrix, and vice versa submatrix written in a matrix, in the case when the matrix is greater than two dimensions in jit.gen?
I understand "sample" operator works only with two-dimensional matrices?
Thank you very much!)
for is a reserved word for a future release. Currently, there is no iteration statement (for, while, …) in GenExpr.
As for sample and nearest. These are both N-dimensional operators. You can sample a 3D, 4D, even 32D matrix with it. sample uses linear interpolation so for high dimensional matrices, it will become expensive. For example, a 32D matrix will have 2^32 corners for a sampled location that have to be interpolated.
Excuse me, but when I try to use the 3Dmatrix and "sample" ,max error:
Object – clang, Message – jit method no module to jit,
Object – clang, Message – not jitted,
Object – jit_gen_interface, Message – could not derive constructor from patcher,
Here is an example, that I am doing wrong?
parameters a and b are working, and when the parameter with nothing happening.
I mean a "c" parameter does not work, that is the third coordinate.
Thanks for pointing this out. ND sampling is fixed for the next release. It’s not in the Gen document right now, but in jitter gen objects, the binary operators (+, -, /, *, %, etc.) can take vector arguments. For example [+ 1 2 3] will add the input to vec(1, 2, 3). In your patch, I noticed you swizzed out the norm components and add them to your params a, b, and c. You can either pack these params as a vector, say [param offset 0 0 0] or do the following [+ a b c].
----------begin_max5_patcher---------- 395.3ocyVFsaBBCEF95xSQSucNSaAb5taOGKlkBzs0EnPfZlaFe2G8TTQiA0 MYxMkv+4PO+70CsrxCQhxWJqH3GwOiQnUdHDHYEPM2iHYhkwohJHMhV9YdzG jQtPF4RCHeGVfivwazyWXRkFyWER2bSH34MgdMWapTeCAX7wzF4BgI9ck9sW JkwF2C4ymVGFyn1rvAOXG4zwzsSkJApcsetexlJqWjoz00FbKqUM0hLnljmJ UhzVo67pKeq3ZOO6vn+FPJDkhrqLP3S8AFLC.RXPW.I7n.gdqARTu.jIT.Hg cAD+gIPD8BP3yNMP3CMfnyKy5iMPB.L3OsKXvXCMZTIxJRkWUdvBccGL3Rvr NAB8n.ge6.hRiY8ANXLW+AsSbLzZOpm0c33xaAl.eM324YpAWkyTosdmgpPR U5C+mCvoV88AQU9hx3MKwMGyi240DYkQoEFUttUN1NWLaaRuqRRj51qVIpJQ TpL4P2M5hsicWiS5m88buZG5YXmf+O6btKV+F6fm6s16G3ccwEH -----------end_max5_patcher-----------
Thank you. So really it is more convenient)))
Forums > Beta