Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# dsp.Buffer System object

Buffer input signal

## Description

The `Buffer` object buffers an input signal. The number of samples per channel in the input must equal the difference between the output buffer size and buffer overlap (i.e., `Length` - `OverlapLength`).

To buffer an input signal:

1. Create the `dsp.Buffer` object and set its properties.

2. Call the object with arguments, as if it were a function.

## Creation

### Syntax

``buff = dsp.Buffer``
``buff = dsp.Buffer(len,ovrlap,ics)``

### Description

````buff = dsp.Buffer` returns a buffer System object™, `buff`, used to buffer input signals with overlap.```

example

````buff = dsp.Buffer(len,ovrlap,ics)` returns a buffer object, `buff`, with `Length` property set to `len`, `OverlapLength` property set to `ovrlap`, and `InitialConditions` property set to `ics`.```

## Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the `release` function unlocks them.

If a property is tunable, you can change its value at any time.

Specify the number of consecutive samples from each input channel to buffer. You can set this property to any scalar integer greater than `0`.

Data Types: `double` | `int32`

Specify the number of samples by which consecutive output frames overlap. You can set this property to any scalar integer in the range $0\le L<{M}_{o}$, where Mo is the output frame size specified by the `Length` property.

The object takes L samples (rows) from the current output and repeats them in the next output. The object acquires ${M}_{o}-L$ new input samples before propagating the buffered data to the output.

Data Types: `double` | `int32`

Specify the value of the object's initial output for cases of nonzero latency as a scalar, vector, or matrix.

When there is nonzero latency, the buffer is initialized to the value(s) specified by the `InitialConditions` property. The object reads from the buffer to generate the first D output samples, where

`$D=\left\{\begin{array}{cc}{M}_{o}+L& \left(L\ge 0\right)\\ {M}_{o}& \left(L<0\right)\end{array}$`

The dimensions of the `InitialConditions` property depend on the `OverlapLength`, L, and whether the input contains a single channel or multiple channels:

• When $L\ne 0$, the `InitialConditions` property must be a scalar.

• When $L=0$, the `InitialConditions` property can be a scalar, or it can be a vector with the following constraints:

• For single-channel inputs, the `InitialConditions` property can be a vector of length Mo if Mi is 1, or a vector of length Mi if Mo is 1.

• For multichannel inputs, the `InitialConditions` property can be a vector of length Mo * N if Mi is 1, or a vector of length Mi * N if Mo is 1.

For general buffering between arbitrary frame sizes, the `InitialConditions` property must be a scalar value, which is then repeated across all elements of the initial output(s). However, in the special case where the input is a 1-by-N row vector, and the output of the block is an Mo-by-N matrix, `InitialConditions` can be:

• An Mo-by-N matrix.

• A length-Mo vector to be repeated across all columns of the initial output(s).

• A scalar to be repeated across all elements of the initial output(s).

In the special case where the output is a 1-by-N row vector, which is the result of unbuffering an Mi-by-N matrix, the `InitialConditions` can be:

• A vector containing Mi samples to output sequentially for each channel during the first Mi sample times.

• A scalar to be repeated across all elements of the initial output(s).

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

## Usage

For versions earlier than R2016b, use the `step` function to run the System object algorithm. The arguments to `step` are the object you created, followed by the arguments shown in this section.

For example, `y = step(obj,x)` and `y = obj(x)` perform equivalent operations.

### Syntax

``y = buff(x)``

### Description

example

````y = buff(x)` creates output `y` based on current input and stored past values of `x` . Output length equals the `Length` property.```

### Input Arguments

expand all

Data input, specified as a column vector or a matrix. The number of input rows must be equal to `Length``OverlapLength`.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `fi`
Complex Number Support: Yes

### Output Arguments

expand all

Buffer output, returned as a column vector or a matrix.

The following table shows the output dimensions of the `dsp.Buffer` System object when the input is a single-channel signal. Mi is the input frame size and Mo is the output frame size specified by the `Length` property.

Input DimensionsOutput Dimensions
1-by-1 (scalar)Mo-by-1
Mi-by-1 (column vector)Mo-by-1

The following table shows the output dimensions of the `dsp.Buffer` System object when the input is a multichannel signal. The output frame size, Mo can be greater or less than the input frame size, Mi. The object buffers each of the N input channels independently.

Input DimensionsOutput Dimensions
1-by-N (row vector)Mo-by-N
Mi-by-N (matrix)Mo-by-N

The data type and complexity of the output matches that of the input signal.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical` | `fi`
Complex Number Support: Yes

## Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named `obj`, use this syntax:

`release(obj)`

expand all

 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

## Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

Create a buffer of 256 samples with 128 sample overlap.

```reader = dsp.SignalSource(randn(1024,1),128); buff = dsp.Buffer(256,128); for i = 1:8 y = buff(reader()); end```

y is of length 256 with 128 samples from previous input.

## Algorithms

This object implements the algorithm, inputs, and outputs described on the Buffer block reference page. The object properties correspond to the block properties, except as noted.