| DSP Blockset | Search  Help Desk |
| Rebuffer | See Also |
Rebuffer the input sequence to a smaller or larger frame size.
Library
Buffers, in General DSPDescription
The Rebuffer block redistributes the input samples to a new frame size, larger or smaller than the input frame size. Rebuffering to a larger frame size yields an output with a slower frame rate than the input.
Rebuffering to a smaller frame size yields an output with a faster frame rate than the input.

The block coordinates the output frame size and frame rate of nonoverlapping buffers so that the sequence sample period (i.e., the sample-to-sample interval) is the same at both the input and output, Tso=Tsi.
The Frame-based inputs check box allows you to choose between sample-based and frame-based operation.Sample-Based Operation
For sample-based operation (default), the Frame-based inputs check box in the parameter dialog box is not selected, and the Rebuffer block creates frame-based outputs from the sample-based inputs. Scalar Inputs. Scalar inputs are buffered into a vector frame (top illustration, initial delay not shown). The size of the output frame, Mo, is determined by the Buffer size parameter. The Buffer overlap parameter specifies the number of samples, L, from the previous buffer to include in the current buffer. The number of new input samples the block acquires before propagating the buffered data to the output is the difference between the Buffer size and Buffer overlap, Mo-L.
The output frame period is (Mo-L)*Tsi, which is equal to the sequence sample period, Tsi, when the Buffer overlap is Mo-1. For negative Buffer overlap values, the block simply discards L input samples after the buffer fills, and outputs the buffer with period (Mo-L)*Tsi, which is slower than the zero-overlap case.
Note
The output frame period of (Mo-L)*Tsi is the same as that for scalar inputs, described above.
Note that the input sample vectors do not begin appearing at the output until the second row of the second matrix. The first output matrix (all zeros in this example) reflects the block's initial buffer, while the first row of zeros in the second output is a result of the one-sample overlap between consecutive output frames. You can use therebuffer_delay function with a frame size of 1 to precisely compute the delay (in samples) for sample-based signals. For the above example,
d = rebuffer_delay(1,3,1)
d =
4
This agrees with the four samples of delay (zeros) shown in the figure above.
Matrix Inputs.
In sample-based operation, an M-by-N matrix input is treated as a single vector with M*N elements. In other words, the matrix input u is reshaped to the vector input u(:).

Frame-Based Operation
For frame-based operation, the Frame-based inputs check box in the parameter dialog box is selected and the Rebuffer block redistributes the samples in the input frame to an output frame of different size and rate. Scalar Inputs. Scalar input processing is the same for frame-based operation as for sample-based operation. The Number of channels parameter must be set to1.
Vector Inputs.
In frame-based operation, a length-Mi vector input represents a single frame of data (Mi sequential samples) from one channel. The Number of channels parameter should correspondingly be set to 1. The Buffer size specifies the size of the output frame, i.e., the number of consecutive samples from the input frame to rebuffer into the output frame. This value, Mo, can be greater or less than the number of samples in the input frame.
The Buffer overlap parameter specifies the number of samples, L, from the previous buffer to include in the current buffer. The number of new samples the block acquires before propagating the buffered data to the output is the difference between the Buffer size and Buffer overlap, Mo-L.
The input frame period is Mi*Tsi, where Tsi is the sequence sample period. The output frame period is (Mo-L)*Tsi, which is equal to the sequence sample period when the Buffer overlap is Mo-1. The output sample period is therefore related to the input sample period by

Note that the sequence is delayed by eight samples, and the first eight output samples adopt the value specified for the Initial condition, which is zero in this example. Use the rebuffer_delay function to determine the length of this initial delay for any combination of frame size and overlap.

Initial Conditions
The Rebuffer block's buffer is initialized to the value specified by the Initial condition parameter, and the block repeats this buffer at the output for the first D steps of the simulation (from t=0 to t=D-1), where D is the initial delay. For sample-based operation, D equals Mo-L. For frame-based operation, use therebuffer_delay function to compute the exact delay (in samples) that the Rebuffer block introduces for a given combination of buffer size and buffer overlap.
For general frame-to-frame rebuffering, the Initial condition must be a scalar value, which is then repeated across all elements of the initial output(s). In the special case where the input is a N-channel sample vector (and the block's output is therefore an Mo-by-N frame matrix), the Initial condition can be:
Dialog Box

See Also
Bufferrebuffer_delay