dsp.AsyncBuffer
FIFO buffer
Description
The dsp.AsyncBuffer
System object™ writes samples to and reads samples from a first-in, first-out (FIFO) buffer.
The write
method writes data to the buffer, and the read
method reads data from the buffer. When creating the object,
you can set the number of samples (rows) of the buffer using the Capacity
property. The number of channels (columns) is set during the first call to write
. Initialize the buffer by calling write
or setup
before the first call to
read
.
The data that you write occupies the next available space in the buffer. If the buffer is
full and all the data within it is unread (asyncBuff.NumUnreadSamples ==
asyncBuff.Capacity
), the object overwrites the oldest data with any new data that
comes in. The buffer removes data only when the data is overwritten, so you can reread data
from the past. The dsp.AsyncBuffer
object supports writing
and reading variable frame size signals. For examples, see Read Variable Frame Sizes from Buffer and Write Variable Frame Sizes to Buffer.
To write and read samples from a FIFO buffer:
Creation
Description
returns an async
buffer System object, asyncBuff
= dsp.AsyncBufferasyncBuff
, using the default
properties.
sets the asyncBuff
= dsp.AsyncBuffer(cap
)Capacity
property to cap
.
Example: asyncBuff = dsp.AsyncBuffer(200000);
Properties
Usage
To write and read samples from the async buffer:
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)
Examples
Limitations
Before calling the read
method, you must initialize the
buffer by calling either the write
or setup
method. For an example, see Why Does the dsp.AsyncBuffer Object Error When You Call read Before write?
Extended Capabilities
Version History
Introduced in R2017a