Controlling Max with Messages
You can control Max, MSP, and Jitter using the message box object. Normally, the message box contains an object, and you click on it or replace a variable typed into the message box to send a message down a patch cord to another Max object. However, if the message in a message box begins with a semicolon (;) followed by the word max, any message which follows will be sent directly to the Max application itself, just as though there were a receive object named "max".
Sending a message to the Max application
- Add a message box to your Patcher, and type in a semicolon and the word max ( ), followed by the message you want to send to Max. Your message box can contain variables (e.g. ).
When you click on the message box or send it a or a value, the message will be sent to the Max application.
Here is listing of the messages you can send to the Max application using this technique:
The word, followed by a reference name symbol and an output filename, builds a collective using the patcher associated with the symbol. The collective is named with the output filename.
The word receive object named by the symbol., followed by a symbol, sends the current Overdrive mode to the
Causes Max not to show a Save Changes dialog when you close a window or quit, even if there are windows that have been modified. This is useful in conjunction with the quit message below.
Clear the Max Console.
The word, followed by a symbol, closes the patcher file previously opened with the message to Max associated with the symbol.
The wordcauses the Max application to terminate and generate a standard crashlog. When relaunched, The Max application will perform standard crash recovery (if crash recovery is enabled in the Max preferences).
Causes Max to write the metadata information currently stored in the database to a file. An optional argument can be used to specify a filename. If no filename is specified, the metadata is backed up to a file in your preferences folder.
Causes Max to load metadata information from a previously stored file into the Max database. An optional argument can be used to specify a filename - when no argument is specified, Max will look for a backup file from a previous call to db.exportmeta in your preferences folder.
Causes Max to recreate the database Max uses when operating (e.g. the File Browser).
The word, followed by a zero or one, toggles the sending of Max's internal debugging output to the Max Console. Debug information may be of limited use for anyone who isn't debugging Max itself.
The word, followed by a one, causes the Core MIDI driver to not create virtual destinations. If an argument of zero is given, the virtual destinations are created again.
The word, followed by a one, causes the Core MIDI driver to not create virtual sources. If an argument of zero is given, the virtual sources are created again.
The word, followed by a zero or one, turns on (or off) Max's search path cache. This should only be done if you noticed unusual behavior when opening files.
(Macintosh only) The word, followed by a zero or one, toggles an alternative to the standard way in which the screen contents are updated, resulting in better visual performance. This feature is enabled by default. The rate at which refresh is done can be set by using the message.
List all of the external objects currently loaded in the Max Console.
The word, followed by two symbols that specify a file extension and a four-character file type, tells Max to associate a filename extension with a particular filetype. The message associates the extension .tx with TEXT (text) files. This allows a user to send a message read george and locate a file with the name george.tx. It also ensures that files with the extension .tx will appear in a standard open file dialog where text files can be chosen.
The word, followed by a floating-point number, sets the ratio of the box to the width of the text when the user chooses Fix Width from the Object menu. The default value is 1.0. A value of 1.1 would make boxes wider than they needed to be, and a value of 0.9 would make boxes narrower than they need to be.
The word receive object, will report the Max version number as a decimal value, which needs to be converted to a hexidecimal value (e.g. Max version 7.3.4 is reported as '1844'), and output from the named receive object., followed by a symbol used as the name of a
Hides the cursor if it is visible.
Hides the menu bar. Although the pull-down menus are not available when the menu bar is hidden, menu shortcut (accelerator) keys continue to work.
The word, followed by an object name as a symbol, looks for a file called <object-name>.html in the search path. If found, a web browser is opened to view the page.
The word, followed by a number from 1 to 20, sets the timing interval of Max's internal scheduler in milliseconds. The default value is 1. This message only affects the scheduler when Overdrive is on and scheduler in audio interrupt (available with MSP) is off. (When using scheduler in audio interrupt mode the signal vector size determines the scheduler interval.) Larger scheduler intervals can improve CPU efficiency on slower computer models at the expense of timing accuracy.
The word, followed by a URL as a symbol, opens a web browser to view the URL. For example:
; max launchbrowser http://www.cycling74.com
Note that Max honors your computer's system preferences - Max won't use subpixel aliasing if you've disabled it for your system. Setting this attribute value to zero value is 0 will always use regular antialiasing, and setting a very high value will always use subpixel antialiasing (unless it is disabled in system preferences).
When using the runtime version of Max *and* an active custom menubar object, , followed by the number 1, will place an item called Status in the Windows menu, allowing users to see the Max Console (labeled Status in the runtime version). When is followed by 0 the menu item is not present. The default is for the Status item to be present in the Windows menu.
Displays the Max Console. If the Max Console if not currently open, the window will be displayed. If the window is currently open, it will bring it to the front.
Prints the names of all current MIDI devices in the Max Console. (See also MIDI Messages to Max, below.)
The word, followed by a zero or one, toggles between using JUCE font rendering (0) and the platform-native font rendering for your computer (1) when displaying text in Max.
(Macintosh) The word, followed by zero or one, sets whether Max saves files with traditional Mac OS four-character type information. By default, Max does save this information in files.
The word *~ object is in a file called times~ so at startup Max executes the command ., followed by two symbols that specify an object name and a file name, creates a mapping between the external object and its filename. For example, the
The word, followed by two symbols that specify an reference name and a file name or path name, attempts to open the patcher with the specified name. If successful, the patcher is associated with the reference symbol, which can be passed as argument to the , , and messages to Max. The message is intended for batch collective building.
List the current search paths in the Max Console. There is a button in the File Preferences window that does this.
The word, followed by a one (on) or zero (off), toggles Overdrive mode.
The word, followed by two integer values that specify horizontal and vertical position, moves the mouse cursor to that global location.
Quits the Max application; equivalent to choosingfrom the File menu. If there are unsaved changes to open files, and you haven't sent Max the message, Max will ask whether to save changes.
Causes all Max Consoles to be updated.
(Macintosh only) The word, followed by a number, sets the rate, in frames per second, at which the visual display is updated. On Macintosh systems, the rate at which the screen is refreshed is unrelated to the rate at which you change its contents. Better visual performance can be achieved - at the cost of a slight performance decrease in Jitter, and little or no performance decrease for audio processing - by specifying a higher frame rate. When enabled using the message, the default rate is 28.57 FPS. Refresh enable is off by default.
The wordcauses the Max application to close and relaunch. If is followed by an optional symbol that specifies a file name or path name, the Max patch referenced by that file name or path will be opened at launch. This is useful in conjunction for situations involving patches which are intended to run unattended (e.g. installations).
The word, followed by a zero or one and a message, executes the message if the current version of Max is a runtime version (1) or non-runtime (0).
The word receive object named by the symbol., followed by a symbol, sends the current scheduler interval to the
The word receive object named by the symbol., followed by a symbol, sends a symbol with the path of the Max application to the
The word, followed by an integer value greater than 100, sets the default patcher height in pixels.
The word, followed by an integer value greater than 100, sets the default patcher width in pixels.
The word, followed by an integer value, sets the time between invocations of the event-level timer (The default value is 2 milliseconds). The event-level timer handles low priority tasks like drawing user interface updates and playing movies.
The word, followed by a 1 or 0, turns on or off (default is 0, off) mirroring of Max Console posts to the system console. The system console is available on the Mac using Console.app, or on Windows using the DbgView program (free download from Microsoft).
The word, followed by a number, sets the time between calls to get the next system event, in 60ths of a second. The default value is 2.
The word, followed by an integer, sets the maximum number of events the scheduler executes each time it is called (The default value is 20). Setting this value lower may decrease accuracy of timing at the expense of efficiency.
The word, followed by an integer value, sets the maximum number of events handled at low-priority each time the low-priority queue handler is called (The default value is 2). Changing this value may affect the responsiveness of the user interface.
The word, followed by a floating-point value, sets the scheduler slop value - the amount of time a scheduled event can be earlier than the current time before the time of the event is adjusted to match the current time. The default value is 25 milliseconds.
The word, followed by a number, sets the maximum number of patcher UI update events to process at a time. Lower values can lead to more processing power available to other low-priority Max processes, and higher values make the user interface more responsive (especially when using many bpatchers).
Shows the cursor if it is hidden.
Shows the menu bar after it has been hidden with.
Prints the number of symbols in the symbol table in the Max Console.
The word, followed by the name of an Operating System (windows or macintosh) and a message, will execute the message if Max is running on the named OS.
The wordfollowed by a one (on) or zero (off) toggles using an external editor for text. If enabled, any situation where an external editor can be used will launch the editor. If disabled, an external editor will only be used when selected from the menu.
The word, followed by a one (on) or zero (off), toggles complete file searching. When enabled, it causes files not found in Max's cache of the search path to be searched in the file system. This is necessary only in extremely rare cases where the file cache does not update properly. One such case is copying a file into the search path using a version of the Mac OS prior to 10.5.5 over a network. This option may cause patcher files to be loaded more slowly. The setting defaults to off with each launch of the application, and is not stored in the user's preferences. turns the setting off.
MIDI Configuration Messages
Messages for creating new MIDI ports:
;#SM createoutport<portname> <drivername>
Creates a new port for the specified driver. This is only possible on Mac machines. Windows is unsupported. On Mac, specifying the DLS synthesizer.driver name creates a virtual output port you can use to communicate with other MIDI applications, while specifying the driver name creates another port exclusively assigned to the
;#SM deleteoutport<portname> <drivername>
On Mac, deletes a port created with themessage. drivername and portname should be the same as the arguments originally passed to .
;#SM driver loadbank<filename> <portname>
On Mac, loads a type 1 or 2 DLS Bank, where filename is the name of an existing DLS bank file, and portname is the name of the port that will use this bank. If portname is omitted, all DLS ports will use the bank. The folder /Library/Audio/Sounds/Banks is added to the search path when looking for a DLS bank file.
;#SM driver loadbank 0<portname>
On Mac, loads the DLS default GM Bank.
;#SM driver reverb<1/0> <portname>
On Mac, turns reverb on or off. By default reverb is off in augraph.
;#SM driver latency<time> <portname>
(midi_mme only) Sets the MIDI Output Latency where time is a value in milliseconds and portname is the port that is set to this value.
;#SM inportinfo<portname> <receive name>
;#SM outportinfo<portname> <receive name>
The receive objects. The information is contained in an message with the following arguments:and messages send information about MIDI ports to named
the port's name (symbol)
the port's driver name (symbol)
the port's unique ID (int)
the port's abbreviation (int)
the port's channel offset (int)
whether the port is enabled or disabled (one if enabled, zero if disabled)
whether the port was created dynamically (one if yes, zero if no)
;#SM createinport<portname> <drivername>
(Mac only) Adds a virtual MIDI input port, where portname is the name you assign to the port, and drivername should be set to. Other MIDI applications can send messages to Max using this port.
;#SM deleteinport<portname> <drivername>
Deletes a port created with themessage. drivername and portname should be the same as the arguments originally passed to .
Ports created with theand messages are not saved as a part of your MIDI setup preferences.
The word, followed by a variable-length message, allows messages to be sent to configure the system MIDI object. These messages need to be prepended with ";max". The following is a list of the available options:
midi portabbrev<innum / outnum> <portname> <abbrev>
innum specifies an input port, outnum specifies an output port, portname is the name of the port as a single symbol (i.e. It is necessary to use double quotes). An abbrev value is 0 for no abbrev (- in menu), 1 for 'a' and 26 for 'z'.
midi portenable<portname> <0/1> <0/1>
The first required argument enables (1) or disables (0) the port specified by portname. The second argument specifies if the target port is an input port (0, default) or output port (1). All ports are enabled by default.
midi portoffset<innum / outnum> <portname> <offset>
Similar to, but offset is the channel offset added to identify input or output ports when a MIDI object can send to or receive from multiple ports by channel number. Must be a multiple of 16 (e.g. sets the channel offset for PortA device to 16).
|Technical Notes||Technical Notes|