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

mtr

Record and sequence messages

Description

Records messages and provides sequenced playback.

Examples

Record MIDI data or other events

Discussion

mtr acts as a multi-track recorder for any kind of message. The leftmost inlet of mtr is a control inlet for all tracks. You can send the same messages to individual tracks as well. Each track records what comes into its inlet, and plays it back through the outlet directly below the inlet.

Arguments

tracks [int]

Optional

Specifies the number of tracks in the mtr. The number of tracks determines the number of inlets and outlets in addition to the leftmost inlet and outlet. Up to 32 tracks are possible. If there is no argument, there will be only one track.

Attributes

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.

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 [float]

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

textjustification [int]

Text Justification

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.

Messages

int

Arguments

input [int]
In any inlet other than the left inlet: If the track is currently being recorded, numbers received in that track's inlet are combined with a delta time (the number of milliseconds elapsed since the previous event) and stored in mtr.

float

Arguments

input [float]
In any inlet other than the left inlet: If the track is currently being recorded, numbers received in that track's inlet are combined with a delta time (the number of milliseconds elapsed since the previous event) and stored in mtr.

list

Arguments

input [list]
In any inlet other than the left inlet: If the track is currently being recorded, lists received in that track's inlet are stored in mtr, preceded by the delta time.

anything

Arguments

input [list]
In any inlet other than the left inlet: If the track is currently being recorded, symbols received in that track's inlet are stored in mtr, preceded by the delta time.

Although mtr can record individual bytes of MIDI messages received from midiin, it stores each byte with a separate delta time, and does not format the MIDI messages the way seq does. If you want to record complete MIDI messages and edit them later, seq is better suited for the task. On the other hand, mtr is perfectly suited for recording sequences of numbers, lists, or symbols from virtually any object in Max: specialized MIDI objects such as notein or pgmin, user interface objects such as number box, slider, and dial, or any other object.

In order for a file to be read into mtr for playback, it must be in the proper format. An mtr multi-track sequence can even be typed in a text file, provided it adheres to the format. The contents of the different tracks are listed in order in an mtr file, and the format of each track is as follows. Note that a semicolon (;) ends each line.

Line 1: track <track number>; (Track in which to store subsequent data)
Line 2, etc.: <delta time> <message>;
Last line: end; (End of this track's data)

clear

Arguments

tracks [list]
In left inlet: Erases the contents of mtr. The word clear, followed by one or more track numbers, clears those tracks.

In other inlets: Erases the track that corresponds to the inlet.

delay

Arguments

delay-time [int]
In left inlet: The word delay, followed by a number of milliseconds, sets the first delta time value of each track to that number, so that all tracks begin playing back that amount of time after the play message is received.

In other inlets: Sets the initial delta time of the track that corresponds to the inlet.

first

Arguments

wait-time [int]
In left inlet: The word first, followed by a number of milliseconds, causes mtr to wait that amount of time after a play message is received before playing back. Unlike delay, first does not alter the delta time value of the first event in a track, it just waits a certain time (in addition to the first delta time) before playing back from the beginning.

next

Arguments

tracks [list]
In left inlet: Causes each track to output only the next message in its recorded sequence. When a next message is received, the track number and the delta time of each message being output are sent out the leftmost outlet as a list. The word next, followed by one or more track numbers, outputs the next message stored in those tracks.

In other inlets: Outputs the next message stored on the track that corresponds to the inlet.

mute

Arguments

tracks [list]
In left inlet: Causes mtr to stop producing output, while still continuing to "play" (still moving forward in the sequence). The word mute, followed by one or more tracks, mutes those tracks.

In other inlets: Mutes the track that corresponds to the inlet.

play

Arguments

tracks [list]
In left inlet: Plays back all messages recorded earlier, sending them out the corresponding outlets in the same rhythm and at the same speed they were recorded. The word play, followed by one or more track numbers, begins playing those tracks.

In other inlets: Plays back all messages on the track that corresponds to the inlet.

read

Arguments

filename [symbol]
In left inlet: Calls up the standard Open Document dialog box, so that a previously saved file can be read into mtr.

In other inlets: Opens a file containing only the track that corresponds to the inlet.

record

Arguments

tracks [list]
In left inlet: Begins recording all messages received in the other inlets. The word record, followed by one or more track numbers, begins recording those tracks.
In other inlets: Begins recording messages on the track that corresponds to the inlet.

rewind

Arguments

tracks [list]
In left inlet: Resets mtr to the beginning of its recorded sequence. This command is used to return to the beginning of the sequence when stepping through messages with next. To return to the beginning of a sequence while playing or recording, just repeat the play or record message. When mtr is playing or recording, a stop message should precede a rewind message. The word rewind, followed by one or more track numbers, returns to the beginning of those tracks.

In other inlets: Returns the pointer to the beginning of the track that corresponds to the inlet.

stop

Arguments

tracks [list]
In left inlet: Stops mtr when it is recording or playing. The word stop, followed by one or more track numbers, stops those tracks.

In other inlets: Stops the track that corresponds to the inlet.

unmute

Arguments

tracks [list]
In left inlet: Undoes any previously received mute messages. The word unmute, followed by one or more track numbers, unmutes those tracks.

In other inlets: Unmutes the track that corresponds to the inlet.

write

Arguments

filename [symbol]
In left inlet: Calls up the standard Save As dialog box, allowing the contents of mtr to be saved as a separate file. Note that the only way to save the contents of mtr is with the write message; the object's contents cannot be embedded in a patcher file.

In other inlets: Writes a file containing only the track that corresponds to the inlet.

Output

anything

Out all track outlets: When a play message is received in the leftmost inlet, the messages stored in each track are sent out the outlet of that track, in the same rhythm and at the same speed they were recorded. A play message received in the inlet of an individual track plays that particular track.

When a next message is received in the leftmost inlet, the next message in each track is sent out its corresponding outlet. The word next, received in the inlet of an individual track, sends out the next message in that track.

list

Out left outlet: Whenever a value is sent out in response to a next message, the track number and delta time of that value are sent out the left outlet as a two-item list.

See Also

Name Description
MIDI MIDI
multislider Display data as sliders or a scrolling display
seq Sequencer for recording and playing MIDI data
rslider Display or change a range of numbers
slider Move a slider to output values