LocalBuf:
Filter:
Classes | UGens > Buffer

LocalBuf : WidthFirstUGen : UGen : AbstractFunction : Object

Allocate a buffer local to the synth
Source: BufIO.sc

Class Methods

LocalBuf.new(numFrames: 1, numChannels: 1)

Allocate a local buffer

Arguments:

numFrames

number of frames (default: 1)

numChannels

number of channels for multiple channel buffers (default: 1)

Returns:

a new buffer – the ugen outputs its buffer number and can thus be used in any other ugen that requires a buffer number input.

LocalBuf.newFrom(list)

Allocates a new buffer from a given list of values

Arguments:

list

The list may be two-dimensional for numChannels > 1. It is then reshaped into the buffer's current format by flattening.

Returns:

a new buffer

Discussion:

Since newFrom is called by the as message, one may thus convert an array to a LocalBuf:

Inherited class methods

Instance Methods

.set(values, offset: 0)

set the buffer slots with a list of values.

Discussion:

If list is smaller than numFrames, it will only set part of the buffer. The list may be two-dimensional for numChannels > 1. offset is the starting index (default: 0)

WARNING: SynthDef permits a maximum of 65536 (2**16) unique constant values in one definition. A very large array of distinct values can corrupt the SynthDef's binary format. If you need a large buffer to be pre-initialized with signal data, it is strongly recommended to use Buffer instead.

If the buffer is large but holds a smaller number of unique values, e.g. Array.fill(88200, { #[0, 0.25, 0.5, 0.75, 1.0].choose }), this is no problem. SynthDef compacts the large array for the list of constants.

.clear

set the buffer slot to zero.

Discussion:

This is important when randomly accessing buffer slots (e.g. with a BufRd) or not overwriting them. Clear is not an efficient real time operation for larger buffers, so it should be only used when really needed - but then it is essential: a LocalBuf is "created" in each new synth, and it may reuse old space. So if an older synth has already ended, this part of memory may be the same as the new synth's.

Inherited instance methods

Undocumented instance methods

.numChannels

.numFrames

Examples