class Buffer
Bind to a Max buffer~
object.
The Buffer object in JavaScript is a companion to the buffer~ object in Max. Through it, you can to access samples and metadata for the buffer~ object with the given name.
Constructors
new Buffer(name: string);
Constructs a new instance of the Buffer
class
Parameter | Type | Description |
---|---|---|
name | string | name of the Max buffer~ to bind to. |
Methods
channelcount
Buffer channel count
channelcount(): number;
Name | Type | Description |
---|---|---|
Return Value | number | The number of channels in the buffer~ object. |
framecount
Buffer frame count
Return the number of frames (samples in a single channel) in the buffer~ object.
framecount(): number;
Name | Type | Description |
---|---|---|
Return Value | number | The number of frames in the buffer~ object. |
freepeer
Free the native C peer
Frees the buffer~ data from the native C peer (created when making a object), which is not considered by the JavaScript garbage collector, and may consume lots of memory until the garbage collector decides to run based JS allocated memory. Once called, the object is not available for any other use. It's not necessary to call this function, as the memory will be freed eventually, but you can call it whenever you're done with your object.
freepeer(): void;
length
Length of the buffer in milliseconds
length(): number;
Name | Type | Description |
---|---|---|
Return Value | number |
peek
Fetch an array of samples from the buffer
peek(channel: number, frame: number, count: number): number[];
Name | Type | Description |
---|---|---|
channel | number | channel to fetch samples from (indexed from 1) |
frame | number | frame at which to start fetching samples (indexed from 0) |
count | number | number of samples to fetch |
Return Value | number[] |
poke
Write samples into the buffer
It is more efficient to call this function once with an array, than to call it mulpitle times, each time with a single sample.
poke(channel: number, frame: number, samples: number | number[]): void;
Name | Type | Description |
---|---|---|
channel | number | channel to write samples to (indexed from 1) |
frame | number | frame at which to start writing samples (indexed from 0) |
samples | number | number[] | samples to write (or a single sample to write) |
send
Send a message to the buffer.
Can send any message that buffer~ understands. See buffer~ reference.
send(message: string, ...args: any[]): void;
Name | Type | Description |
---|---|---|
message | string | the name of message |
args | any[] | arguments that follow the name of the message |