📜 ⬆️ ⬇️

Max / MSP Review

In my previous article I was asked to write a small review of Max / MSP, it seems that at Habré they are not very familiar with this wonderful tool.

Preamble


Max is a visual programming language for creating real-time applications. Initially, it was created as a tool for musicians, but in its more than twenty years of history it turned into a universal tool that allows to solve any tasks related to sound, image and interaction with a person or equipment. Most often it is used to create interactive installations, algorithmic music and visuals, although, thanks to the open API and the ability to write your own objects, it can be used for any purpose that requires working in real-time. Here, for example, is an installation built on one of the buildings in the Italian city of Cagliari. The color of LED displays varies with car noise and is controlled by a bunch of Max / MSP and Arduino .



A bit of history


The first version of Max, the direct descendant of which is described in this article, was written by Miller Puckett in the late 80s when he worked at IRCAM (Institut de Recherche et Coordination Acoustique / Musique, Institute for Research and Coordination of Acoustics and Music) . At that time there were collected the best minds of the world engaged in research in the field of computer music, among which, in particular, was Max Matthews , the pioneer of electronic music, the man who created the first music program MUSIC I.
')
The name Max was given in his honor, however it was done not for his services, but because he developed the “real-time scheduling” algorithm RTSKED , which was the basis of Miller’s program. Its essence is as follows: the calculations take place in several parallel elements that perform something for a while, then inform the system about the completion, after which they remain idle until a trigger signal is received. This is the fundamental idea of max (program).

But Max did not always know how to work with audio due to the low computing power of old processors. Initially, such an opportunity appeared in the PureData program, which Miller wrote after leaving IRCAM and based on ideas that he had laid down earlier. It was in her first opportunity to synthesize sound in real time ( Max / FTS does not count, because it used a special DSP card for the synthesis). Shortly after the creation of Pd, David Zicarelli , the founder of Cycling'74 , decides to add audio to the original max, which is what made Max / MSP appear. For the synthesis, it uses the PureData infrastructure, to which features taken from Max / FTS but not implemented in Pd were added.

A bit later, Cycling'74 created Jitter , a set of objects that allow real-time work with video, 3D and OpenGL, based, if I'm not mistaken, on GridFlow , a similar development for jMax , the direct heir to Max / FTS .

Let's sum up. Max is a visual programming environment, the foundation of everything; MSP is an extension that makes it possible to work with audio, and Jitter is an extension for working with video. Hence the name - Max / MSP / Jitter .

Max has a very long history, for whom it is interesting, it is better to read Miller's article - who, if not the creator, will describe ee better? We need to take the first steps ...

Getting Started


First, we analyze some of the basics. The program in max is called a patch . To create a patch, it is necessary to connect various modules using virtual wires (they are usually called objects ), as a rule, performing simple functions such as arithmetic, sorting, MIDI processing, wave synthesis, and so on. Each object has entrances and exits, which we will further call inlets and outlets . I will tell you more about everything in one of the following articles, and I’ll limit myself to just step-by-step instructions for creating a small random sequencer that controls a simple synthesizer.

So, in order to get started, you need to install the program by downloading the latest demo version from the official site cycling74.com . After a successful launch, the Max window will appear on the screen - the Max service window, where errors and other system messages are displayed.

image

Now you can create an empty patcher - a window in which you will collect your first patch . This is done from the menu File> New Patcher (Ctrl N) .

An empty patcher opened before us. Max tells us to double click on an empty spot. This action will open the object palette - a small menu from which you can select an object . Personally, I find it inconvenient, since it is much faster to add an object using the keyboard. To do this, press the “n” button to create an empty object (object box) , in which you must enter the name of the object and press enter . In this way, we will create three objects: toggle , button and [metro 300] and connect them, as shown in the figure.

image

The toggle and button objects miraculously turned into cute buttons. Their difference is that the first is a switch, and the second plays the role of a trigger. Now we leave the edit mode by clicking on the lock in the lower left corner of the screen, and click on the toggle object. As a result, the button should flash. What is going on? When turned on, the toggle object sends the unit to the left inlet of the object [metro 300], which turns on and starts generating a special bang trigger message every 300 milliseconds and transmitting it to the button , causing the latter to blink. By the way, the [metro 300] object is a metro object with one argument of 300 . Arguments specify the initial parameters of the objects.

Now turn off the toggle and go back to edit mode. Add three objects: [random 24] , [+ 48] and number and connect, as shown in the figure:

image

Now turn on the toggle again and see what happens. As mentioned earlier, the [metro 300] object generates a bang every 300 milliseconds. This bang enters the object [random 24] , forcing which to generate a random number in the range 0 ... 23 . Then, using the object [+ 48], we add to the output of the random 48 , thereby obtaining at the output a range of 48 ... 71 . The generated numbers are displayed in the number object (called the number box ), which displays integer values.

Moving on, now we will generate sound. To do this, we need to add four more objects: mtof , cycle ~ , gain ~ and ezdac ~ . I want to note that in all cases in the names of objects the tilde mark is obligatory - this agreement, adopted in max , allows to distinguish MSP objects (which work with audio) from ordinary ones. Yes, by the way, initially the object gain ~ had a vertical view, in this patch I changed it by simply hovering the cursor on the lower right corner of the object and stretching it to the desired size, as is done with the windows of my favorite OS. Pay attention to the new striped wires - this is how the wires through which the MSP signal is transmitted look like.

image

Once again, exit edit mode (for those who have already forgotten, this is done using the lock icon in the lower left corner), turn on toggle , drag the gain ~ slider to the right and click on ezdac ~ . A sound should appear. If this does not happen, go to Settings > DSP Status ... and select the desired audio driver and audio interface. For our example, the ad_mme driver is quite appropriate, since asio is not needed for such simple work. When I select zvukovuhi max hieroglyphs, so here you may have to experiment, but practice shows that the very first device in the list is usually suitable. After all the manipulations, you must again click on ezdac ~ to enable MSP .

image

So, we deviated a little, we still have to explain how everything works. In the previous patch, we stopped at generating random numbers in the range of 48 ... 71 . We feed these numbers into the mtof object, it understands the numbers 0 ... 127 as MIDI notes and transforms them into the appropriate frequency. For example, note number 60 has a frequency of 261 Hz , note 70 - 466 Hz, and so on. This value enters the cycle ~ object and sets it to the frequency of the generated sine wave. Then the signal enters the object gain ~ , which allows you to change the amplitude, and then goes to the speakers through the ezdac ~ object (short for easy digital audio converter ), which does two things: it actually outputs audio to the speakers and turns MSP on / off.

Go ahead. Now add an ADSR -bending for amplitude. To do this we need the following objects: [trigger f 1] , adsr ~ , * ~ (multiplication of signals), three number and one flonum . Now connect all together:

image

The structure has slightly changed, we will analyze everything here. The output from mtof now goes to the [trigger f 1] object, which, when a message arrives at it, first outputs the unit from the right outlet, thereby forcing adsr ~ to generate a new envelope, and then output the number entered into it through the left outlet. From the arguments everything should be clear: f - means float , and 1 - one . Here one important feature of all objects is used - the display of messages starts from the right outlet and in turn to the left . I will tell you more about this next time, as this is not included in the scope of the introductory article. Let's go back to the patch. As it has already become clear, adsr ~ generates an envelope, the parameters of which are set using four namber boxes. Important: the parameters attack , decay and release are specified in milliseconds, therefore for their cases the number objects were used. For convenience, the range of these values ​​was limited to 0 ... 1000 in the inspector, which is invoked by right-clicking on an object and invoking the Inspector menu.

image

The sustain parameter sets the amplitude, therefore its range of values ​​consists of real numbers 0 ... 1.0 . That is why instead of number the object flonum is used - it is completely identical to number , it only allows you to work with real numbers. By the way, the minimum and maximum of it are also limited through the inspector to 0 and 1, respectively.
Finally, the signal from adsr ~ multiplies with the signal cycle ~ and is output to the columns. That's it, your first patch is ready! Easy, isn't it?

What's next?


I did not intend this article to paint all the subtleties of working with max, since it is simply impossible to fit in ten A4 pages (this is exactly how much my article takes in a Word). I wanted to give only a general idea of ​​this wonderful program, showing the principle of work in it, while trying not to slip into insanity and worthlessness (many thanks to everyone who helped me in this). If there is interest, I can write a series of articles in which I will detail in detail the important things of Max (types of messages, sequence of events, etc.), and who do not have the patience to wait for this, I cite the main directions for self-study.

Firstly, tutorials that come with max and are available from the Help menu are required to read. They contain in detail and consistently all the fundamental things necessary for work. Max has great documentation, to be honest, I haven't seen anything like it in other programs. What are only interactive examples for each object.

Secondly, on the official website of cycling74.com there are a lot of small video lessons showing various "chips". Also there is the world's largest forum dedicated to this program; if there are difficulties, it is better to use the search on the forum: most likely this situation has already arisen in someone before.

Although these two resources are plenty to explore, I was once helped by the book Programming Electronic Music in Pd by Johannes Kreidler , although it is dedicated to PureData (in fact, there are more similarities than differences between Pd and Max ). The book is published in the public domain, the English translation can be read on the link .

And I would like to mention two Russian-speaking resources:
1. http://maxmsp.ru - site created by Dmitry Dubrov and Dmitry Letakhovsky, known by the project Fizzarum;
2. http://pattr.ru is a blog that we support with friends, created to, to some extent, compensate for the lack of Russian-language material on the Max / MSP and PureData programs.

Also, it is worth scrolling tutorials on max made by comrade Phoiod , for convenience, I uploaded them to scribd . They are on the fourth max, but for study it is quite suitable, especially if the English is tight.

For now. Happy Patching! :)

Archive with patches can be downloaded from the link .

Source: https://habr.com/ru/post/127972/


All Articles