Use the sfplay~ object to play audio files from disk. Supported formats include AIFF, WAVE, MP3, M4A, NeXT/SUN(.au), and Raw Data.
To play a file, you send sfplay~ the message, then send it a to start and a to stop. takes an argument to specify a filename in the search path. You can also create additional cues with the message. These can reference other files, all of which are simultaneously accessible. The message sets the "current" file: the one that plays back from the beginning when is sent and is used as the default for the message. sfplay~ can also connect to the cues defined in an sflist~ object. Since multiple sfplay~ objects can reference the same sflist~, this allows you to store a global list of cues.
Sets the number of output channels, which determines the number of signal outlets that the sfplay~ object will have. The maximum number of channels is 28. The default is 1. If the audio file being played has more output channels than the sfplay~ object, higher-numbered channels will not be played. If the audio file has fewer channels, the signals coming from the extra outlets of sfplay~ will be 0.
An additional optional argument can be used to specify the disk buffer size in samples. The default disk buffer size is 120960, and disk buffer sizes must be specified as multiples of 20160. If this argument has a value of 0, the default disk buffer size will be used.
An additional optional argument can be used to create outlets to the sfplay~ object which display positioning information. Specifying a final argument of
Like all MSP audio signals, this playback position is a 32-bit single precision floating-point signal. If greater precision is desired, specifying a final argument of 2 creates a second outlet which outputs a second 32-bit single precision floating-point signal containing the single precision roundoff error. Together these signals provide near double precision floating-point accuracy. (Note: after several minutes a single precision floating-point value is no longer sample accurate) Using the two signals together with objects such as the unsupported Max/ MSP high resolution signal processing objects like hr.+~ , one may perform sample-accurate calculations based on file position
If the last argument is a symbol, it specifies a name by which other objects can refer to the sfplay~ object to access its contents.
Specifies the name/pathname of an audio file to be loaded by the sfplay~ object.
Sets a tuning standard based on a frequency for A for pitch correction operations (440 = default, range is 400 - 500)
When followgobaltempo is enabled, sfplay~ will calculate the current tempo out of the ratio between originaltempo and global tempo and adapt to global tempo changes.
formant [float] (default: 1.)7.0.0
The word, followed by floating point value, sets the amount of formant scaling when pitchshifting is performed.
The word, followed by a zero or one, disables/enables formant correction when pitch correction is performed.
Sets the timestretching mode to be used. Each mode is optimized for handling different kinds of audio material. All modes are zero latency.
'basic' ( Default mode of operation )
This is the default mode of operation.
'monophonic' ( Monophonic sources (voice, flute) )
This mode is best for monophonic instruments (e.g. solo voice, flute, etc.)
'rhythmic' ( Optimizes for transient preservation )
This mode is for time stretched percussion. It provides optimal transient preservation.
'general' ( Balance spectral integrity with transient preservaton )
This mode balances spectral integrity and transient preservation for general cases.
'extremestretch' ( For stretch ratios greater than 2.0 )
This mode is intended for stretch ratios greater 2.0, a more artistic effect is intended.
'efficient' ( Good CPU performance )
This mode is intended for a good CPU performance/quality tradeoff.
originallength [10 atoms]7.0.0
The original length of the the audio file in beats. Used byto calculate the speed in relation to the global transport speed. Setting the will calculate the .
The original tempo of the the audio file. Used byto calculate the speed in relation to the global transport speed. Setting the will calculate the .
The word retune~ object., followed by a zero or one, enable/disables the formant-corrected chromatic intonation correction. For more extensive real-time intonation correction, use the
pitchshift [float] (default: 1.)7.0.0
Specify pitchshift as a factor of the original pitch (i.e. 2.0 = doubling of pitch, .5 = halving of the original pitch, etc.).
pitchshiftcent [int] (default: 0)7.0.0
Specify pitchshift as positive or negative cent values (i.e. 100 = semitone up, -1200 = octave down). Cents may be specified as ints or floats.
Choose the quality for timestretching output.
'basic' ( Basic quality (the default) )
'good' ( Good quality )
'better' ( Better quality )
'best' ( Highest quality )
slurtime [float] (default: 0.)7.0.0
Set the time it takes for the correction to reach the full correction amount. Typically, notes are a bit unstable at the beginning, because the attack phase of a sound has a higher amount of noise, and because singers gradually adjust their tuning after the onset of the note. The slur time makes the pitch correction sound natural because it models this effect. Higher values will yield a slower adaptation time and it will take longer for the correction to produce the corrected pitch. However, longer slur times will also preserve vibrato better.
The word, followed by a zero or one, disables/enables timestretching.
Common Box Attributes
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.adds the object to the background layer, 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.
Sets the type style used by the object. The options are:
0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'
Sets the object's font.
Sets the object's font size (in points).
hidden [int] (default: 0)
Toggles whether an object is hidden when the patcher is locked.
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]
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]
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]
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.
Sets the color for the object's text in RGBA format.
0 = 'left'
1 = 'center'
2 = 'right'
To initiate starting from a cue point with a negative speed, bidirectional cues must be used.
There are a number of forms for the message. The word is followed by an obligatory cue number between 2 and 32767. If the cue number is followed by a filename of a file in Max's search path, or a full file pathname, that cue number will play the specified file. Note that a file need not have been explicitly opened with the 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 , 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 (bidirectional buffering off).
A final optional argument is used to set the playback speed. A float value sets the sfplay~ object's playback speed relative to the object's global playback speed -- set set by either the message or the sfplay~ object's right inlet. The default value is .
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.
The message is always deferred to low priority. The , , and messages are not. If you have problems with these messages arriving before you want them to in overdrive mode (i.e., before you've preloaded the most recent cue), use the defer object.
The following types of sample data are supported:
The following types of sample data are supported:
: 8-bit integer
: 16-bit integer
: 24-bit integer
: 32-bit integer
: 32-bit floating-point
: 64-bit floating-point
: 8-bit "mu"-law encoding
: 8-bit a-law encoding
NOTE: The message is always deferred to low priority. If you have problems with these messages arriving before you want them to in overdrive mode (i.e. before you've finished seeking to a new location), then use the defer object.
Out right outlet: When the file is done playing, or when playback is stopped with amessage, a is sent out.
There is one signal outlet for each of the sfplay~ object's specified output channels (set by or as an argument to the sfplay~ object) that sends out the audio data of the corresponding channel of the audio file when a cue number is received in the inlet. (The left outlet plays channel 1, and so on.)
If the optional output position argument is specified, there will be one or two signal outputs following the channel outputs whose signal outputs display positioning information. If the argument is , a single outlet to the left of the rightmost "bang on finish or halt" outputs a signal containing the current playback position in milliseconds. Specifying a final argument of creates a second outlet which outputs a signal containing the playback position single precision roundoff error in milliseconds (see Arguments for a more detailed description of the sfplay~ object's position outlets).
|buffer~||Store audio samples|
|groove~||Variable-rate looping sample playback|
|play~||Position-based sample playback|
|sfinfo~||Report audio file information|
|sflist~||Store audio file cues|
|sfrecord~||Record to audio file on disk|
|MSP Sampling Tutorial 6: Record and Play Audio Files||MSP Sampling Tutorial 6: Record and Play Audio Files|