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

peek~

Read and write sample values

Description

The peek~ object will function even when the audio is not turned on. You can use peek~ to treat buffer~ as a floating-point version of the Max table object in non-signal applications.

Arguments

Name Type Opt Description
buffer-object-name symbol Obligatory. Names the buffer~ object whose sample memory is used by peek~ for reading and writing.
buffer-channel int opt Following the buffer~ name, you can type in a number to specify the channel in a multi-channel buffer~ to use for subsequent reading or writing operations. The default is 1.
clipping-enable-flag (0 or 1) int opt An optional third argument after buffer name and channel can be used to enable clipping. If the third argument is a one, then -1.0 to 1.0 clipping is enabled. You can also change this setting using the clip message.

Messages

int sample-index [int]
In left inlet: A sample index into the associated buffer~ object's sample memory. The value stored in the buffer~ at that index is sent out the peek~ object's outlet. However, if a value has just been received in the middle inlet, peek~ stores that value in the buffer~ at the specified sample index, rather than sending out a number. If the number received in the left inlet specifies a sample index that does not exist in the buffer~ object's currently allocated memory, nothing happens.

In middle inlet: Converted to float.
  (inlet2) buffer-channel [int]
In right inlet: A channel (from 1 to 4) specifying the channel of a multi-channel buffer~ to be used for subsequent reading or writing operations.
float sample-index/buffer-channel [float]
In left inlet: Converted to int.

In right inlet: Converted to int.
  (inlet1) sample-index [float]
In middle inlet: A sample value to be stored in the associated buffer~. The next sample index received in the left inlet causes the sample value to be stored at the index.
list sample-index value and buffer-channel [list]
In left inlet: The second number is stored in the associated buffer~ at the sample index specified by the first number. If a third number is present in the list, it sets the channel of a multi-channel buffer~ in which the value will be stored. Otherwise, the most recently set channel is used.

Note that for int, float, and list, if the message refers to a sample index that does not exist in the buffer~ object's sample memory, nothing happens. You can ensure that memory is allocated to the buffer~ by reading an existing file into it, by typing in a duration argument, or by setting its memory allocation with the size message.
clip clipping-enable-flag (0 or 1) [int]
In left inlet: The word clip, followed by a non-zero number, enables -1.0 to 1.0 clipping. Clipping is enabled by default. Clipping can be disabled with the message clip 0.
(mouse) Double-clicking on peek~ opens an editing window where you can view the contents of its associated buffer~ object.
set buffer-object-name [symbol]
In left inlet: The word set, followed by the name of a buffer~ object, associates peek~ with that newly named buffer~ object.

Information for box attributes common to all objects

Output

float: The sample value in a buffer~, located at the table index specified by a float or int received in the left inlet, is sent out the peek~ object's outlet.

Examples

Peek at samples in a buffer~ and/or set the value of the samples

See Also

Name Description
buffer~ Store audio samples
buffir~ buffer-based FIR filter
poke~ Write sample values to a buffer by index
table Store and graphically edit an array of numbers