A newer version of Max is available. Click here to access the latest version of the documentation

matrixctrl Reference

Matrix switch control

matrixctrl

Description

Provides a user interface control containing a group of cells in a grid. Cell states can either be on/off or incremental steps. This object is especially useful for controlling the matrix~ object.

Examples

matrixctrl can be used to control multiple gates and switches at once

Discussion

matrixctrl is a user interface object that consists of a rectangular grid of switch-like controls called cells. All of the cells in a matrixctrl object have the same appearance and behavior. Each cell has two or more states. By default, the cells have two states, representing "off" and "on." You can create cells with any number of states. Clicking on a cell increases its state by one. After a cell reaches its last state, it returns to its zero state when clicked again--thus, a cell with only two states will toggle back and forth between these states with each mouse click.

matrixctrl was originally constructed to control the MSP object matrix~, but is useful for other user interface applications, such as groups of switches, groups of visual indicators, and drum-machine-oriented sequencers.

Note: The matrixctrl object customarily uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows, we recommend that you install QuickTime and choose a complete install of all optional components to work with images other than PNG or PICT files.

Arguments

None.

Attributes

active [int] (default: 1)

Toggles matrixctrl to ignore or respond to mouse clicks, respectively. By default, matrixctrl responds to mouse clicks.

autosize [int] (default: 0)

Toggles automatically resizing to rows and columns for the matrixctrl object's display area when a cell picture is added.

bgcolor [4 floats]7.0.0

Sets the default background color in RGBA format.

bkgndpict [symbol] (default: <default>)

Designates the graphics file that the matrixctrl object will use for the matrix background image. By convention, the matrixctrl object uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows and want to to work with images other than PNG or PICT files, we recommend that you install QuickTime and choose a complete install of all optional components. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/CoolBkgnd.png"). The word bkgndpicture by itself puts up a standard Open Document dialog box.

cellpict [symbol] (default: <default>)

Designates the graphics file that the matrixctrl object will use for each cell. By convention, the matrixctrl object uses images saved in Portable Network Graphics (.png) format. If you are using Max on Windows and want to to work with images other than PNG or PICT files, we recommend that you install QuickTime and choose a complete install of all optional components. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/Cell.png").

clickedimage [int] (default: 1)

Specifies that the graphics file used by the matrixctrl object contains an additional image to be displayed when a cell is clicked.

clickvalue [atom_long] (default: -1)

Toggles the click value mode. If the clickvalue message is followed by a zero or a positive number, clicking on a cell sets its value to the given number. If clickvalue is followed by a negative number, the matrixctrl object reverts to its default behavior in which clicking a cell increments its value. The clickvalue message allows the use of the matrixctrl object to create grid editors by creating graphics files which contain a sequence of images, each of which is assigned to a different value; as you click through the sequence of images, the cell image will change to reflect velocity, note, etc.

color [4 floats]7.0.0

Sets the default color for a cell in the "on" state in RGBA format.

columns [atom_long] (default: 8)

Sets the number of columns in the matrixctrl object's display.

dialmode [int] (default: 0)

Determines how individual cells in matrixctrl are activated and if cell values are stored as integers or floats. The default is 0 (off). Possible values:

0 = 'Off' ( Allows cells within the matrix to react to a simple click. )
1 = 'Indexed' ( Allows the object to behave like a matrix of dials where a cell will need to be clicked and dragged on to change its value. )
2 = 'Gain' ( Similar to Indexed mode, Gain causes the object to behave like a matrix of dials where a cell will need to be clicked and dragged on to change its value. However, this mode is for float gain tracking, where cell values are stored as floats. )

dialtracking [int] (default: 0)

Sets whether or not the matrixctrl object will use vertical mouse tracking while it is in dialmode.

elementcolor [4 floats]7.0.0

Sets the default color for a cell in the "off" state in RGBA format.

horizontalmargin [atom_long] (default: 1)

Sets a horizontal margin (in pixels) between the outermost cells and the edge of the matrixctrl object's bounding box.

horizontalspacing [atom_long] (default: 0)

Sets the horizontal distance (in pixels) between adjacent cells in the matrixctrl object.

imagemask [int] (default: 0)

Specifies that the matrixctrl cell graphics file has additional rows of images for use as image masks. This attribute is present for legacy support - it has been superseded by the use of alpha channels in images.

inactiveimage [int] (default: 1)

Specifies that the matrixctrl cell graphics file has additional rows of images for use in an inactive state (set with an active 0 message).

invisiblebkgnd [int] (default: 0)

Specifies that the matrixctrl will be drawn without a background image, and its cells will be superimposed over any underlying Max objects. invisiblebkgnd 0 disables this feature.

one/column [int] (default: 0)

One Non-Zero Cell Per Column

one/matrix [int] (default: 0)

Toggles only allowing one cell in the entire object to have a non-zero state. Setting any other cell in the matrix to a non-zero state causes any other non-zero cells to change to the zero state. one/matrix 0 removes this constraint.

one/row [int] (default: 0)

Toggles only allowing one cell per row to have a non-zero state. Setting any cell in a row to a non-zero state causes any other non-zero cells to change to the zero state. one/row 0 removes this constraint.

parameter_enable [int]

Enables use of this object with Max for Live Parameters and allows for setting initial parameter values in the Max environment.

parameter_mappable [int] (default: 1)

When parameter_mappable is enabled, the object will be available for mapping to keyboard or MIDI input using the Max Mappings feature.

range [atom_long] (default: 2)

Sets the number of possible states each cell can have. It must be set to a value of at least 2 (for states 0 and 1).

rows [atom_long] (default: 4)

Sets the number of rows in the matrixctrl object's display.

scale [int] (default: 1)

Toggles scaling graphics when the matrixctrl object's display area is resized.

style [symbol] (default: )7.0.0

Sets the style to be applied to the object. Styles can be set using the Format palette.

verticalmargin [atom_long] (default: 1)

Sets a vertical margin (in pixels) between the outermost cells and the edge of the matrixctrl object's bounding box.

verticalspacing [atom_long] (default: 0)

Sets the vertical distance (in pixels) between adjacent cells in the matrixctrl object.

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points). Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

jspainterfile [symbol]

JS Painter File

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [4 floats]

Sets the color for the object's text in RGBA format.

textjustification [int]

Sets the justification for the object's text. Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Parameter Attributes

Order

Typeint

Sets the order of recall of this parameter. Lower numbers are recalled first. The order of recall of parameters with the same order number is undefined.

Parameter Mode Enable

Typeint

Parameter Mode Enable (not available from Parameters window)

Link to Scripting Name

Typeint

When checked, the Scripting Name is linked to the Long Name attribute.

Long Name

Typesymbol

The long name of the parameter. This name must be unique per patcher hierarchy.

Short Name

Typesymbol

Sets the short name for the object's visual display. The maximum length varies according to letter width, but is generally in a range of 5 to 7 characters.

Type

Typeint

Specifies the data type. The data types used in Max for Live are:

Float
Int
Enum (enumerated list)
Blob

Note: By convention, the Live application uses floating point numbers for its calculations; the native integer representation is limited to 256 values, with a default range of 0-255 (similar to the char data type used in Jitter). When working with Live UI objects whose integer values will exceed this range, the Type attribute should be set to Float, and the Unit Style attribute should be set to Int.

Range/Enum

Typelist

When used with an integer or floating point data type, this field is used to specify the minimum and maximum values of the parameter.
When used with an enumerated list (Enum) data type, this field contains a space-delimited list of the enumerated values (if list items contain a space or special characters, the name should be enclosed in double quotes).

Clip Modulation Mode

Typeint

Sets the Clip Modulation Mode used by the Live application. The modulation modes are:

None
Unipolar
Bipolar
Additive
Absolute

Clip Modulation Range

Typelist

This parameter is only used with the Absolute modulation mode. It specifies defines the range of values used.

Initial Enable

Typeint

When checked (set to 1), the UI object can store an initialization value. The value is set using the Initial attribute (see below).

Initial

Typelist

Sets the initial value to be stored and used when the Initial Enable attribute is checked.

Unit Style

Typeint

Sets the unit style to be used when displaying values. The unit style values are: Int: displays integer values
Float: displays floating point values
Time: displays time values in milliseconds (ms)
Hertz: displays frequency values (Hz/kHz).
deciBel: displays loudness (dB)
%: Percentage
Pan: displays Left and Right values
Semitones: displays steps (st)
MIDI: displays pitch corresponding to the MIDI note number
Custom: displays custom data type
Native: defaults to floating point values

Custom Units

Typesymbol

Sets the units to be used with the 'Custom' unit style (see "Unit Style", above). Custom unit strings may be simple symbols (e.g. "Harmonic(s)"), in which case the parameter's value will be displayed in its 'Native' display mode, followed by the symbol (e.g. "12 Harmonic(s)" for an Int-typed parameter or "12.54 Harmonic(s)" for a Float-typed parameter). For additional control over the numerical component displayed, a sprintf-style string may be used (e.g. "%0.2f Bogon(s)", which would display a value such as ".87 Bogons").

Exponent

Typefloat

When set to a value other than 1., the parameter's input and output values will be exponentially scaled according to the factor entered in this column.

Steps

Typeint

The number of steps available between the minimum and maximum values of a parameter. For instance, if the parameter has a range from 0.-64., with Steps set to 4, the user can only set the parameter to 0, 21.33, 42.66 and 64.

Parameter Visibility

Typeint

For automatable parameters (Int, Float, Enum), 'Stored Only' disables automation, although parameter values are stored in presets. 'Hidden' causes the parameter's value to be ignored when storing and recalling data. Non-automatable parameters (Blob) are 'Stored Only' by default, and can be set to 'Hidden', if desired.

Update Limit (ms)

Typeint

Speed limits values triggered by automation.

Defer Automation Output

Typeint

Defers values triggered by automation.

Messages

bang

bang causes matrixctrl to dump its current state in lists of three values for each cell pair, in the format

horizontal-coordinate vertical-coordinate value

list

Arguments

values [list]
A list of ints sets cells in the matrixctrl object using the format <horizontal-coordinate vertical-coordinate value>. Multiple triplets of values can be used to set more than one cell. Coordinates for the cells start at 0 in the upper-left hand corner and the values for each cell start at 0 and go up to the value range minus one, set by the object's inspector. Substituting the symbols inc and dec in place of the value will increment or decrement that cell coordinate by a value of one. Changing the cell state with a list causes the list to be output from matrixctrl.

bkgndpicture

Arguments

filename [symbol]
This is a legacy message - it has been superseded by the bkgndpict attribute.

cellpicture

Arguments

filename [symbol]
This is a legacy message - it has been superseded by the cellpict attribute.

clear

The word clear will set the value of all cells to 0.

dictionary

TEXT_HERE

disable

Arguments

coordinates [list]
Performs the same as disablecell.

disablecell

Arguments

coordinates [list]
The word disablecell, followed by a list of number pairs which specify the horizontal and vertical coordinates of a cell or cells, sets the designated cell or cells so that they do not respond to mouse clicks. The disablecell message expects at least one pair of numbers, but more may be added to disable multiple cells (e.g., disable 0 0 3 4 9 12). Although disabled cells will ignore mouse clicks, their values can be set using messages.

enablecell

Arguments

coordinates [list]
The word enablecell, followed by a list of number pairs which specify the horizontal and vertical coordinates of a cell or cells, will set any designated cell or cells which have been disabled using the disablecell message to respond to mouse clicks again. The enablecell message expects at least one pair of numbers, but more may be added to enable multiple cells (e.g., enable 1 1 1 2 2 2).

getcolumn

Arguments

column [int]
The word getcolumn, followed by a number, sends the values of the cells in the column designated by the number out its right outlet. Column numbers start at 0.

getrow

Arguments

row [int]
The word getrow, followed by a number, sends the values of the cells in the row designated by the number out its right outlet. Row numbers start at 0.

(mouse)

A mouse click on a cell will increase its value by one. Values in matrixctrl will wrap back to 0 once they have reached their maximum possible state. Dragging across several cells will set their values to that of the first cell clicked. Dragging across cells while holding down the Shift key will allow you to drag in straight horizontal or vertical lines only.

readanybkgnd

Arguments

filename [list]
The word readanybkgnd followed by the name of a file will read any type of file into the matrixctrl object and attempt to interpret it as a background image.

readanycell

Arguments

filename [list]
The word readanycell followed by the name of a file will read any type of file into the matrixctrl object and attempt to interpret it as a cell image.

set

Arguments

input [list]
The word set, followed by a list as described above, changes the state of matrixctrl without echoing the values to the output.

Picture File Format

Specifications

The background pictures the matrixctrl object uses are, by convention, saved in Portable Network Graphics (.png) format. If you are using Max on Windows and want to to work with images other than PNG or PICT files, we recommend that you install QuickTime and choose a complete install of all optional components. The symbol used as a filename must either be the name of a file in Max's current search path, or an absolute pathname for the file (e.g. "MyDisk:/Documents/UI Pictures/Cell.png"). If the matrixctrl is larger than the chosen picture, copies of the picture will be added to fill the object.

Cell picture files must be in the following format:





The picture is made up of a grid of images. All images have the same width and height. Each column of images represents one cell state. The picture must have at least two columns, since cells must have at least two states.

The first row of images is used for the idle (or "not clicked") appearance of the cells. The first row of images is mandatory; all subsequent rows are optional. The second row are images for the clicked appearance; these images will be used to draw the cell when it is clicked. The appearance of the cell reverts to its idle image when the mouse is released. The third row of images are used when the matrixctrl is in its inactive state, i.e. when it has received an active 0 message.

Image masks can be used to create cells with non-rectangular outlines. These masks are in the lower rows of the picture file. If you wish to use masks for any of the cell images, you must provide masks for all of them--each row of images will have a corresponding row of masks. Like all masks for Max's picture-based controls, black pixels create areas of the corresponding image that will be drawn, and while pixels create invisible areas.

Output

list

When a cell changes state in response to a mouse click, a list is sent out the matrixctrl object's left outlet. The list contains the column, row, and value (state) of the clicked control. Individual cells can also be set by sending lists to the object's left inlet. Rows and columns are numbered starting with zero, at the upper-left corner of the matrix.

The numbers received in the inlet are compared with the arguments. If the numbers are the same, and in the same order, they are sent out the outlet as a list.

See Also

Name Description
crosspatch Patching Editor for Matrix Objects
dial Output numbers using an onscreen dial
kslider Output numbers from an onscreen keyboard
matrix~ Signal routing and mixing matrix
pictctrl Picture-based control
pictslider Picture-based slider control
router Route messages to multiple locations
rslider Display or change a range of numbers
slider Move a slider to output values
ubutton Transparent button
Max Basic Tutorial 21: Controlling Data Flow Max Basic Tutorial 21: Controlling Data Flow
Tutorial 26: MIDI Control of Video Tutorial 26: MIDI Control of Video