Week 9 - Class 1
This session, we are going to examine some of the ways to have Max patches communicate with each other. Why would we bother?
- You might need to improve performance by running on several machines.
- You might choose to encapsulate your work into several independent pieces.
- You might want to create a collaborative environment between individuals and their machines.
- You might want to impress me with your technical acumen!
The example fixtures for the class can be found in this file
In the first case, we look at the send and receive objects:
Send and receive (or s and r, as they are most often abbreviated) are used to send messages from one section of a patch to another, or between concurrently running patches. You can send anything that includes a standard Max message, which means that numbers, symbol or even Jitter matrices can be sent/received with these objects.
The only thing that won't work are audio data; because of its streaming nature, you need to use a different set of objects: send~ and receive~. These act similar to send and receive, but cannot be abbreviated (too sad!).
Next, we need to look at the udpsend and udpreceive objects:
These use the OSC communications standard to send data between machines over the network. This can either be a local network connection or a Internet connection; however, since it does use the UDP protocol, it is subject to misordered packets and lost data. So beware!
But the cool thing is that it is a network equivalent of the send and receive objects (in that it can send arbitrary Max messages). The only limitation is that you cannot send jit.matrix data, since the shared memory used by a matrix won't be available on the remotely connected machine!
Another option is to use the communications options available through the mxj (Java) objects:
Java has a lot of networking options available, and the mxj object exposes them through a series of net.* classes. The most useful is the mxj net.tcpsend and mxj net.tcpreceive combo, which uses the TCP protocol for more secure - and more robust - communication. But there are a variety of options (including multicasting or super-simple message sending); you can see many of them in action by opening the mxj net.maxhole object's help file and clicking the messages at the bottom!
Finally, we have to deal with Jitter images. Since the normal use of Jitter depends on shared memory, send/receive options just don't work. But there are two objects: jit.net.send and jit.net.receive:
The jit.net.send object 'serializes' the contents of the jit.matrix, turning it into something similar to a GIF file that is sent out the network. The receiver gets the image and re-codes it into a jit.matrix. This is the only way to pull this off; none of the previous methods can be used for over-the-network transmission of jitter data of any sort (including OpenGL data).
One thing to notice about all of the networking options: senders require two pieces of data (the host's network address and send port), while receivers only require one (the receive port, since the host address is expected to be the current machine network address). But you have to be careful when you set this up, because modern computer, network and router systems have all sorts of port limitations, anti-phishing options and other anti-hacking lock-downs that can prevent machine-to-machine communications. In order to get this working, you'll need control over all of the machines, and enough network knowledge (or a good net-hacking friend) to pull it off.
Let's talk about The Class Final:
The Final is pretty simple: it is a project that will encapsulate all of the knowledge you've gained in this quarter's class. So it should probably include some sort of hardware interface, OpenGL visualzation and maybe some cross-machine interaction. You should also use the skills you gained in VP I, including audio/music, video data (maybe as textures) and camera/projector use. Even more than previous work, this one needs to be Great Work, and show both an artistic vision and technical skills to meet the vision.
You can work individually, as a duo or even a larger team. Before you leave the class, let me know the configuration of your team (or solo, if you prefer), and provide me with some sort of starting concept of where you will be going.
In the rest of the classes, I'm going to provide some simple ideas for additional techniques, but all of the rest of the classes will be about finishing the Final Project. If you are aggressive about the selection of this project, you will probably learn more in its creation that anything I can teach you!
Week 9 - Class 2
This class, we are going to take a quick look at the maxurl object. Unfortunately, this is a complex object, and can take you down a rabbit hole of detail. Let's start by taking a look at some simple examples (in this file).
Our first case is using a simple, http-based API. A good example is random.org. This gives us a variety of random outputs, and has a basic API interface that you can find about this link. We can use this API to get random numbers in this way:
We can get several kinds of information - including floats and strings - and we can even get multiple instances of the information. In the next case, we use the interface to get random strings, treat them like a list of strings, then examine them by unpacking the lists into individual symbols:
The biggest problems come with either complex API's or situations where no API exists. For example, if we try to get access to Google's "Hot Trends" website, we can only get the raw HTML - and deferred data - when we access the data:
The result is next to useless, is too big to deal with effectively, and is a distraction from data of which we might actually be able to make artful use.
Please continue your work on your Final Project. If you are having technical issues, today is a good day to clear them up. You should leave feeling like you know what you are doing, and you've communicated the project goals to me!