The Buffer object in JavaScript is a companion to the buffer~ object you instantiate in Max patchers, and provides the ability to access samples and metadata for the buffer~ object with the associated name.
Buffer Constructor
var buf = new Buffer("name")
The name is required at the time the object is created.
The following methods relate to the functionality from the Max buffer~, info~, peak~, and poke~, objects. Please see the references for those objects for details.
Buffer Methods
channelcount
Return the number of channels in the buffer~ object.
framecount
Return the number of frames (samples in a single channel) in the buffer~ object.
length
Return the length of the buffer~ object in milliseconds.
peek
Arguments
frame [int]
count [int]
Return an array with
samples from (1-based counting) starting at (zero-based counting).poke
Arguments
frame [int]
samples [float/array]
Write into the buffer~ object at (1-based counting) and (0-based counting). Samples may be a single sample value or an array of sample values. It is computationally more efficient to use an array).
send
Arguments
arguments [anything]
Send a message to the associated buffer~ object. Can send any message that buffer~ understands.
Examples
Example code can be found in the "js" tab of the buffer~ help patcher.
See Also
Name | Description |
---|---|
JavaScript Usage | JavaScript Usage |