Before we start patching today, I want to give you an overview of new objects we will be using, so that you will already have heard about them once we are using them in a bigger context. Also we will summarize some familiar objects, which are also important for today. Make sure to check the help patches for additional information. This is only a very short overview.
Counter
The first object we will be using a lot in the future is the counter object. We have already built our own counter using a + and number box. There is also a ready-made counter which is much more powerful build in max. The counter counts bangs it receives and can count up , down and up and down. It also can stay in a specified range. Here an easy example:
This counter will count one step every second (because it receives a bang every second). It counts upwards, which is specified by the first argument. It counts from 1 to 3 which is specified by the second and third argument. Its output will be 1,2,3,1,2,3,1,2,3,… until the metro stops.
Int and Float
The int can store and output any given integer number.
For example:
Send and receive
The following example demonstrates the use of the send and receive objects. They can replace patchcords and transmit the messages wirelessly. Every message you can send via a patchcord can also be transmitted via send and receive. The example:
You need the same argument (name) for the send and receive object.
Prepend and append
Sometimes we want to add something to a message we send. We can add something to a message using the prepend and append objects. The prepend object is used to add something at the beginning of an object, the append object to add something at the end.
The help patches give a nice example:
Similarly, the append object:
Random
Another object you will need in the future is the random object. The random object puts out a random number:
All of those random objects put out a random number within the range between 0 and 1 less than the argument specified, here that means 0-42.
Compare
Compare (“==“) compares two numbers and outputs 1 if they are equal and a 0 if they are not. Also, there is a whole collection of similar objects like “<” (less than),”<=” (less than or equal to) “>” (greater than), “>=” (greater than or equal to) and “!=” (not equal). Some examples:
Modulo
The % (modulo) divides two numbers and outputs their reminders.
Gate
Gate is used to pass input out a specific outlet. The gate can also be opened and closed so messages can or can not pass. The message is send in the right inlet, the left inlet is used to specify whether and where the message should be send out… Some examples:
Pack
Pack can combine numbers and symbols into a list. Two examples:
By the way, there is also unpack which does exactly the opposite.
zl
The zl object is used for multi-purpose list processing. Today, we are mainly interested in “zl compare” which allows us to compare two lists. zl compare will tell us whether two lists are equal and if they differ, it will tell us in which indexes are different. An easy example:
Route
Route is used to selectively pass the output out a specific outlet. It looks at the first part of an message and tries to match it to its own arguments. If it finds a match, it sends the following part (without the matching argument) of the message out of the corresponding outlet.
In short, route routes.
Table
The table is mainly used to store and graphically edit an array of numbers. Add a table and double click. Then draw in the table:
You have just put numbers into an array. If you want to retrieve the numbers you have drawn into the table, you can access them like this:
This means, that if you go to the right to index number 34 you have drawn a ‘hight’ of 71. We can also say the value of the index 34 is 71. Of course you do not have to draw. You can also put in values to the table like this:
And retrieve it again like this:
The table can only store combinations of numbers (index+value), no symbols or lists. If you need to store those, use a coll.
The range and size of a table can be adjusted. This produces a table with the indexes 0-99 where every value can either be a 0 or a 1:
sfplay~
The last object we get to know is actually a MSP object. This means it is used for audio-stuff. You can immediatly see this from the tilde behind the object name. You can imagine this tilde as a little soundwave which indicates that this object deals with sound. The sfplay~ is used to play an audio file from the hard disk. The object can play AIFF, NeXT/SUN(.au), WAVE, and Raw Data files. It works a bit like any sound player you know. You can load files and play them. Furthermore, you can preload several files and define cues which access those. You can play the file from beginning to end but also access the file at any given millisecond. A very simple player could look like this:
Actually, we have cheated here a bit because yous ee quite a lot new objects. There is also a slider called gain~ which is used to scale the output volume and a little speaker-button called ezdac~ (speak easydac), which is used to put on and off the audio output (dac stands for Digital-To-Analog-Converter). You don’t have to understand all this right now, but it is handy to know that sound files can be played back like this.