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


Store audio file cues


sflist~ stores a list of preloaded cues for sound files that can be accessed by multiple sfplay~ objects. Each sflist~ object has a unique name that sfplay~ objects use to refer to its cues. Defining a cue is the same for sflist~ as for sfplay~. You can preload cues for sflist~ without the audio being on.


Name Type Opt Description
object-name symbol Obligatory. Names the sflist~. sfplay~ objects use this name to refer to cues stored inside the object.
buffer-size int opt Sets the buffer size used to preload audio files. The default and minimum is 16384. Preloaded buffers are 4 times the buffer size per channel of the audio file.


clear cue-numbers [list]
The word clear with no arguments clears all defined cues. After a clear message is received, only the number 1 will play anything (assuming there's an open file). The word clear followed by one or more cue numbers removes them from the sflist~ object's cue list.
cuedump The word cuedump will cause sflist~ to send out the outlet a listing containing all of its cues.
embed saving-preference-flag (0 or nonzero) [int]
The message embed, followed by any non-zero integer, causes sflist~ to save all of its defined cues and the name of the current open file when the patcher file is saved. The message embed0 keeps sflist~ from saving this information when the patcher is saved. By default, the current file name and the cue information is not saved in sflist~ when the patcher is saved. If an sflist~ object is saved with stored cues, they will all be preloaded when the patcher containing the object is loaded.
fclose filename [symbol]
The word fclose, followed by the name of an open file, closes the file and removes all cues associated with it. The word fclose by itself closes the current file.
open filename [symbol]
The word open, followed by the name of an AIFF, WAV, or NeXT/Sun audio file, opens the file if it is located in Max's search path. Without a filename, open brings up a standard open file dialog allowing you to choose a file. When a file is opened, its beginning is read into memory, and until another file is opened, playing from the beginning the file is defined as cue 1. Subsequent cues can be defined referring to this file using the preload message without a filename argument. When the open message is received, the previous current file, if any, remains open and can be referred to by name when defining a cue with the preload message. If any cues were defined that used the previous current file, they are still valid even if the file is no longer current.
preload cue-number filename start-time end-time directional-flag and playback-speed [list]
Defines a cue, an integer greater than or equal to 2, to refer to a specific region of a file. When that cue number is subsequently received by an sfplay~ object that is set to use cues from the sflist~ object, the specified region of the file is played by sfplay~. Cue number 1 is always the beginning of the current file - the file last opened with the open message - and cannot be modified with the preload message.

There are a number of forms for the preload message. The word preload is followed by an obligatory cue number between 2 and 32767. If the cue number is followed by a filename - a file that is currently open or one that is in Max's search path - that cue number will henceforth play the specified file. Note that a file need not have been explicitly opened with the open message in order to be used in a cue. If no filename is specified, the currently open file is used.

After the optional filename, an optional start time in milliseconds can be specified. If no start time is specified, the beginning of the file is used as the cue start point. After the start time, an end time in milliseconds can be specified. If no end time is specified, or the end time is 0, the cue will play to the end of the file. If the end time is less than the start time, the cue is defined but will not play. Eventually it may be possible to define cues that play in reverse.

After the start and/or end time arguments, a optional directional buffer flag is used to enable reverse playback of stored cues. Setting this flag to 1 enables reverse cue playback. The default setting is 0 (bidirectional buffering off).

A final optional argument is used to set the playback speed. A float value sets the playback speed for an sfplay~ object relative to the object's global playback speed -- set by the speed message. The default value is 1.

Each cue that is defined requires approximately 40K of memory per sfplay~ channel at the default buffer size (40320), with bidirectional buffering turned off. With bidirectional buffering turned on, the amount of memory per cue is doubled.
print Prints a list of all the currently defined cues.

Information for box attributes common to all objects


Cues: Cues are stored within the object for reference by other soundfile objects. A listing of internally stored cues is sent out its outlet with the cuedump message.


Store a global list of cues that can be used by one or more sfplay~ objects

See Also

Name Description
buffer~ Store audio samples
groove~ Variable-rate looping sample playback
play~ Position-based sample playback
sfinfo~ Report audio file information
sfplay~ Play audio file from disk
sfrecord~ Record to audio file on disk
MSP Tutorial 16: Record and Play Audio Files MSP Tutorial 16: Record and Play Audio Files