Package Max

seq

Sequencer for recording and playing MIDI data

Description

seq is a sequencer of raw MIDI bytes. You can control the speed of playback (only at the time you start it), read and write from files, and record from live MIDI input. See also midiparse and midiformat which you may need to get to and from raw MIDI.

Arguments

filename[symbol]
optional

Specifies the name of a file to be read into seq automatically when the patch is loaded.

Attributes

overridetempo[int]: 0

If enabled (default = 0 (disabled)), the value of the tempo attribute will override any tempo requested by the sequence. In this case, tempo attribute will not be updated when a new file is read, nor when tempo meta messages appear in the sequence data. The meta messages will continue to be output from the right outlet of the seq object in this case.

sequencetempo[float]
read-only

The unmodified tempo of the sequence. This is a read-only value for convenience purposes.

tempo[float]: 120.

If the seq has read a MIDI file with tempo information, the tempo attribute will reflect the current tempo at the current playback time. If the file has no tempo information, the default tempo is 120. (120 BPM). The tempo attribute can be modified to change the playback speed, but will be overwritten by tempo changes present in the MIDI file, and will be overwritten when a new MIDI file is read.

Common Box Attributes

Below is a list of attributes shared by all objects. If you want to change one of these attributes for an object based on the object box, you need to place the word sendbox in front of the attribute name, or use the object's Inspector.

annotation[symbol]

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

background[int]: 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]: 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]: 0

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

jspainterfile[symbol]

You can override the default appearance of a user interface object by assigning a JavaScript file with code for painting the object. The file must be in the search path.

patching_rect[4 floats]: 0. 0. 100. 0.

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

position[2 floats]
write-only

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]: 0

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

presentation_rect[4 floats]: 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]
write-only

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]
write-only

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.

Messages

bang

Starts playing the sequence stored in seq.

int

When seq is recording, numbers received in its inlet are interpreted as bytes of MIDI messages (usually from midiformat or midiin). MIDI channel messages and system exclusive messages can be recorded by seq, but seq does not respond directly to MIDI real time messages such as start, stop, MIDI clock, etc.

Arguments:
  • input [int]

float

Converted to int .

Arguments:
  • input [float]

addeventdelay

The word addeventdelay , followed by a number, adds to the delay onset time, in milliseconds, of the first event in the recorded sequence. All events in the sequence are shifted so that the first event occurs at the specified onset time.

Arguments:
  • onset-time (milliseconds) [float]

append

Starts recording at the end of the stored sequence, without erasing the existing sequence.

clear

Clears the sequence currently stored in the seq object.

delay

The word delay , followed by a number, sets the onset time, in milliseconds, of the first event in the recorded sequence. All events in the sequence are shifted so that the first event occurs at the specified onset time.

Arguments:
  • onset-time (milliseconds) [int]

dump

Opens a standard Open Document dialog box, to select a saved sequence or standard MIDI file. The selected file is opened as text in a new Untitled text window, which can be edited and saved.

hook

The word hook , followed by a float, multiplies all the event times in the stored sequence by that number. For example, if the number is 2.0, all event times will be doubled, and the sequence will play back twice as slowly. Multiplications can even be performed while the sequence is playing.

Arguments:
  • event-time-multiplier [float]

print

Prints the first sixteen events of the recorded sequence in the Max Console.

read

With no arguments, read calls up the standard Open Document dialog box, so that a previously recorded sequence can be read into seq, replacing the current sequence. With a symbol as an argument, read searches for a file with the specified name to read into the seq object.

Note: The seq object reads and writes both single track (format 0) and multi-track (format 1) standard MIDI files. It can also read and write text files in which each line consists of a start time in milliseconds (the time elapsed since the beginning of the sequence) followed by the (space-separated) bytes of a MIDI message recorded at that start time. For example,



0 144 60 112;

1000 144 60 0;

1500 192 31;

1500 144 60 112;

2500 144 60 0;

plays the note middle C on channel 1 for one second, then half a second later changes to program number 31 and plays middle C again for one second.

Arguments:
  • filename [symbol]

record

Starts recording MIDI messages received in the inlet.

start

The word start by itself has the same effect as bang . The word start , followed by a number, plays the stored sequence at a tempo determined by the number. The message start 1024 indicates normal tempo. If the number is 512 , seq plays the sequence at half the original recorded speed, start 2048 plays it back at twice the original speed, and so on.

The message start -1 starts the sequencer, but rather than follow Max's millisecond clock, seq waits for a tick message to advance its clock. See the tick message.

Arguments:
  • tempo-multiplier [int]

stop

Stops the sequencer if it is recording or playing. A stop message need not be received when switching directly from playing to recording, or vice-versa.

tick

After seq has received a start -1 message, it waits for tick messages to advance its clock. In order to play the sequence at its original recorded tempo, seq must receive 48 tick messages per second. This is equivalent to 24 tick s per quarter note (the standard for a MIDI Clock message) at a tempo of 120MM. By using tick messages to advance the sequencer, you can vary the tempo of playback or synchronize seq with another timing source (such as incoming MIDI Clock messages).

write

Calls up the standard Save As dialog box, so that a recorded sequence can be saved as a separate file. If you want to edit the sequence with the text editor, check the Save As Text option in the dialog box. With a symbol as an argument, write will write a file with the specified name. A non-zero int argument (as a single argument, or following a filename argument) will cause the seq object to write a multi-track standard MIDI file (format 1).

Arguments:
  • filename [symbol]
  • format [int]

Output

bang

Out middle outlet: Indicates that seq has finished playing the current sequence. (The bang is sent out immediately before the final event of the sequence is played.)

int

Out left outlet: When bang or start is received in the inlet, the sequence stored in seq is sent out the outlet in the form of individual MIDI bytes, usually to be sent to midiparse or midiout.

list

Out right outlet: If the current sequence loaded by seq contains MIDI meta messages, these are sent from the right outlet, prepended with the word meta , followed by the name of the meta metssage and the data.

Known meta messages are: sequencenumber , text , copyright , sequenceortrackname , instrumentname , lyric , marker , cuepoint , midichannelprefix , endoftrack , tempo , smpteoffset , timesignature , keysignature , sequencerspecific . Any other messages will be identified as unknown . The text messages ( text , copyright , sequenceortrackname , instrumentname , lyric , marker , cuepoint ) are converted to symbols. The tempo meta message is displayed as a BPM value.

See Also

Name Description
coll Store and edit a collection of data
follow Compare a live performance to a recorded performance
mtr Record and sequence messages