buffer~
Description
Use the buffer~ object as a buffer of memory in which samples are stored to be saved, edited, or referenced.
Examples
Discussion
The buffer~ object is used in conjunction with many different objects, including play~ / groove~ (plays the buffer), record~ (records into the buffer), info~ (reports information about the buffer), peek~ (writes into/reads from the buffer like the table object), lookup~ (uses the buffer for waveshaping), cycle~ (specifies a 512-point waveform), and wave~ (specifies a waveform).
Arguments
name [symbol]
The first argument is a name used by other objects to refer to the buffer~ to access its contents.
For information about using named objects in Max for Live, click here.
filename [symbol]
After the buffer~ object's name, you may type the name of an audio file to load when the buffer~ is created.
duration [number]
After the optional filename argument, a duration may be provided, in milliseconds, to set the size of the buffer~, which limits the amount of sound that will be stored in it. (A new duration can be specified as part of a message, however.) If no duration is typed in, the buffer~ has no sample memory. It does not, however, limit the size of an audio file that can be read in.
channels [int]
After the duration, an additional argument may be typed in to specify the number of audio channels to be stored in the buffer~. (This is to tell buffer~ how much memory to allocate initially; however, if an audio file with more channels is read in, buffer~ will allocate more memory for the additional channels.) buffer~ may have an arbitrary number of channels, only limited by the amount of RAM available. By default, buffer~ has one channel.
Attributes
dither [int] (default: 0)
Enable triangular dithering when writing PCM (integer) files.
Possible values:
0 = 'Off'
(
Apply no dithering when writing PCM files
)
1 = 'Dither'
(
Apply triangular dither (TPDF) when writing PCM files
)
2 = 'Dither + Noise Shaping'
(
Apply triangular dither with noise shaping (HP-TPDF) when writing PCM files
)
filetype [symbol]
The audio file format used by the buffer~ object. The default file type is AIFF.
Possible values:
'aiff'
(
Apple Interchange File Format (default)
)
'wave'
(
WAVE
)
'raw'
(
raw
)
'au'
(
NeXT/Sun
)
format [symbol]
The bit depth or sample type of the buffer on disk
For backward compatibility, the following numeric valus can be used to set format, in addition to the symbolic names below:
8 - 8-bit integer
16 - 16-bit integer
24 - 24-bit integer
32 - 32-bit integer
Possible values:
'int8'
(
8-bit integer
)
'int16'
(
16-bit integer (default)
)
'int24'
(
24-bit integer
)
'int32'
(
32-bit integer
)
'float32'
(
32-bit floating-point
)
'float64'
(
64-bit floating-point
)
'mulaw'
(
8-bit mu-law encoding
)
'alaw'
(
8-bit a-law encoding
)
quantization [int] (default: 0)
Select the quantization rule when writing PCM (integer) files.
Possible values:
0 = 'Round'
(
Round when quantizing to integer values.
)
1 = 'Floor'
(
Floor when quantizing to integer values.
)
samps [int]
The length of the buffer~ expressed in samples.
size [float]
The length of the buffer~ expressed in milliseconds.
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.
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.
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]
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.
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
(remote)
(drag)
apply
Arguments
The word , followed by a single symbol that designates a windowing function, will apply that function to the current contents of the buffer~. Supported functions include triangle, hamming, hanning, blackman, welch, and kaiser. An additional second symbol argument of (e.g. ) will calculate the function and apply only the second half to the whole buffer~.
Note: The kaiser function requires a second floating point argument that specifies the beta parameter and precedes an optional argument (e.g. ).
The word , followed by the word and a floating-point number that specifies a gain value, will scale every sample by the gain coefficient. and a floating-point number that specifies a constant value that will be added to every sample in the buffer~.
The word , followed by the word , will replace every sample value with the a new value representing the difference from the previous sample.
clear
clearlow
crop
Arguments
(mouse)
duplicate
Arguments
enumerate
fill
Arguments
The word , followed by a single floating-point number, will set every sample in the buffer~ to that value.
The word , followed by a symbol that designates a function, will fill the buffer~ with one cycle of that function. Supported functions include sin (sine), cos, (cosine), and sinc. An optional second argument (e.g. ) can be used to define the number of cycles of the function used to fill the buffer~. An additional optional third argument defines a rational number of cycles with which to fill the buffer~ (e.g. will fill a buffer~ with a quarter cycle of the cosine function).
Note: the sinc function requires two arguments that specify the number of zero crossings and an additional flag that toggles starting the function at zero (e.g. ).
import
Arguments
The buffer~ object uses QuickTime to convert a media file (including MP3 files) into the sample memory of a buffer~, and requires that QuickTime be installed on your system. If you are using Max on Windows, we recommend that you install QuickTime and choose a complete install of all optional components.
Since the message uses QuickTime, which specifies units of time for all files as 1/600 of a second rather than milliseconds, importing is not guaranteed to start at the specified offset with millisecond accuracy.
The starting time may be followed by a second argument - a floating point value that specifies the duration of sound, in milliseconds, to be read into buffer~. This duration overrides the current size of the object's sample memory. If the duration is specified by a negative value, buffer~ reads in the entire file and resizes its sample memory and adjusts the number of channels in the file accordingly.
The duration may be followed by a third argument that specifies the number of channels to be read in. If the number of channels is not specified (i.e., if the message includes only offset and duration information), buffer~ reads in the number of channels indicated in the header of the audio file.
If only two arguments are specified, buffer~ imports the number of channels indicated in the header of the audio file. If three arguments are specified, buffer~ imports the number of channels specified by the third argument. If the third argument is 0, buffer~ imports the number of channels indicated in the header of the audio file.
importreplace
Arguments
name
Arguments
normalize
Arguments
open
printmodtime
read
Arguments
The starting time may be followed by a second argument - a floating point value that specifies the duration of sound, in milliseconds, to be read into buffer~. This duration does not override the current size of the object's sample memory. It clears the current buffer~ data, then fills the requested amount at the beginning of the buffer~. However, if the duration is specified by a negative value, buffer~ reads in the entire file and resizes its sample memory.
The duration may be followed by a third integer argument that specifies the number of channels to be read in.
If only two arguments are specified, buffer~ reads in only the number of channels that the buffer~ currently has. If the audio file has more channels than the buffer~ currently has, the audio from all channels will be summed. If three arguments are specified, buffer~ reads the number of channels specified by the third argument. If the third argument is 0, buffer~ reads in the number of channels indicated in the header of the audio file.
readagain
Arguments
readraw
Arguments
sample-rate [float]
channels [int]
format [symbol]
byte-offset [int]
duration-in-frames [int]
little-endian-flag [int]
The optional arguments are:
- buffer~ (default = open file dialog) : a filename or filepath to read into
- : the sample-rate of the data to be read (default = )
- : the number of channels of the data to be read (default = )
- : the format to read; one of , , , or (default = )
- : the byte offset in the file where reading should begin (default = )
- : the total number of samples to read per channel, a value of reads from to the end of the file (default = )
- : whether to read samples using big-endian ( ) or little-endian ( ) byte order (default = )
replace
Arguments
samptype
Arguments
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
set
Arguments
setsize7.0.0
Arguments
number-of-channels [int]
sizeinsamps
Arguments
number-of-channels [int]
sr
Arguments
wclose
write
Arguments
writeaiff
Arguments
writeflac
Arguments
writeraw
Arguments
format [symbol]
duration-in-frames [int]
little-endian-flag [int]
The optional arguments are:
- : a filename or filepath to save the raw file (default = open save dialog)
- : the format to write; one of , , , or (default = )
- buffer~ object. A value of writes the entire buffer to disk (default = ) : the total number of samples to write per channel (number of channels is determined by the contents of the
- : whether to write samples using big-endian ( ) or little-endian ( ) byte order (default = )
writewave
Arguments
Output
bang
Right outlet: A bang is sent out the right outlet of buffer~ when the file read or file write operation is completed.
See Also
Name | Description |
---|---|
Working with Video in Jitter | Working with Video in Jitter |
2d.wave~ | Two-dimensional wavetable |
buffir~ | buffer-based FIR filter |
cycle~ | Sinusoidal oscillator |
groove~ | Variable-rate looping sample playback |
info~ | Report information about a sample |
lookup~ | Transfer function lookup table |
peek~ | Read and write sample values |
play~ | Position-based sample playback |
poke~ | Write sample values to a buffer by index |
polybuffer~ | Manage multiple buffer~ objects |
record~ | Record sound into a buffer |
sfplay~ | Play audio file from disk |
sfrecord~ | Record to audio file on disk |
stretch~ | Ztx-based pitch/time modification of an audio buffer |
wave~ | Variable size wavetable |
MSP Basics Tutorial 3: Wavetable Oscillator | MSP Basics Tutorial 3: Wavetable Oscillator |
MSP Sampling Tutorial 5: Waveshaping | MSP Sampling Tutorial 5: Waveshaping |
MSP Sampling Tutorial 1: Recording and Playback | MSP Sampling Tutorial 1: Recording and Playback |
MSP Sampling Tutorial 3: Playback with Loops | MSP Sampling Tutorial 3: Playback with Loops |
MSP Sampling Tutorial 4: Variable-length Wavetable | MSP Sampling Tutorial 4: Variable-length Wavetable |
MSP MIDI Tutorial 3: MIDI Sampler | MSP MIDI Tutorial 3: MIDI Sampler |
MSP Analysis Tutorial 3: Using the FFT | MSP Analysis Tutorial 3: Using the FFT |