FileStreaming
Discussion
THIS MODULE IS DEPRECATED AND NOT RECOMMENDED FOR NEW DESIGNS. PLEASE USE THE Source MODULE INSTEAD.
This module is used to stream data from MATLAB to the target in real-time. The module has two internal buffers, a small "transfer" buffer and a large "circular" buffer. MATLAB writes data into the transfer buffer one block at a time. The module then copies the data from the transfer buffer to the circular buffer. The size of the transfer buffer is specified at instantiation time by the parameter, TRANSFERSIZE. The buffer is allocated to be TRANSFERSIZE+1 words in length.
Handshaking occurs between the module and MATLAB by the last word in the transfer buffer. When the last word of the transfer buffer equals 0, then the module is ready to accept data. MATLAB should write data into the transfer buffer and then set the last word equal to 1. The handshaking flag is added to the end of the array so that data and handshaking can occur with a single write.
Since the circular buffer is written transferBufferSize words at a time, the prefillLevel must be a multiple of transferBufferSize.
At startup, the module does not begin outputing data. Rather, it waits until the prefill level of the circular buffer has been reached. Prefilling enables the module to output data at a stready stream without an initial glitch.
The variable, currentFillLevel indicates how many data samples are available in the circular buffer to the output. The variable, underflowCount indicates how many output samples could not be supplied due to lack of data. underflowCount is not incremented during the initial prefill operation.
The output of the module is a single integer which points to a data structure in memory. By manipulating the data structure, a downstream module can pull data out of the module's circular buffer.
Module Pack
Deprecated
ClassID
classID = 2011
Type Definition
typedef struct _ModuleFileStreaming
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
INT32 transferBufferSize; // Size of the transfer buffer, in 32-bit words.
INT32 circularBufferSize; // Size of the circular buffer, in 32-bit words.
INT32 prefillLevel; // Circular buffer fills to this number of words before data is output.
INT32 underflowCount; // Number of output words that could not be serviced.
INT32 currentFillLevel; // Number of available words in the circular buffer.
INT32 isReady; // Boolean that indicates whether the module is ready to output data.
INT32 isPrefilling; // Boolean that indicates whether the module is waiting for prefill data. While waiting, the module does not output data.
INT32 asyncStatus; // Used to pass asynchronous messages (pause/stop/play) from the PC to the target.
INT32 playbackState; // Indicates the current state of the player: FIOS_Stopped, FIOS_Playing, FIOS_Paused. Starts out in FIOS_Stopped.
INT32 isNewStream; // Boolean that indicates whether the player has just output the first block of a new file.
INT32 fileExtension; // First 4 letters of the file extension, each packed as a byte into the word.
INT32 writeIndex; // Index at which to write data into the circular buffer.
INT32 readIndex; // Index at which to read data out of the circular buffer.
INT32* transferBuffer; // Data transferred from PC to target DSP via this buffer.
INT32* circularBuffer; // Data transferred from PC to target DSP via this buffer.
} ModuleFileStreamingClass;
Variables
Properties
| Name | Type | Usage | isHidden | Default Value | Range | Units |
|---|---|---|---|---|---|---|
| transferBufferSize | int | const | 0 | 256 | 1:1000000 | 32-bit words |
| circularBufferSize | int | const | 0 | 1024 | 1:1000000 | 32-bit words |
| prefillLevel | int | parameter | 0 | 512 | Unrestricted | 32-bit words |
| underflowCount | int | state | 0 | 0 | Unrestricted | words |
| currentFillLevel | int | state | 0 | 0 | 0:1024 | words |
| isReady | int | state | 0 | 0 | 0:1 | |
| isPrefilling | int | state | 0 | 1 | 0:1 | |
| asyncStatus | int | state | 0 | 0 | Unrestricted | |
| playbackState | int | state | 0 | 4 | Unrestricted | |
| isNewStream | int | state | 0 | 0 | Unrestricted | |
| fileExtension | int | state | 0 | 0 | Unrestricted | |
| writeIndex | int | state | 1 | 0 | Unrestricted | |
| readIndex | int | state | 1 | 0 | Unrestricted | |
| transferBuffer | int* | parameter | 0 | [257 x 1] | Unrestricted | |
| circularBuffer | int* | parameter | 1 | [257 x 1] | Unrestricted |
Pins
Output Pins
| Name | ID |
| Description | Pointer to the streaming transfer object |
| Data Type | int |
Matlab Usage
File Name: file_streaming_module.m
M=file_streaming_module(NAME, TRANSFERSIZE, CIRCBUFSIZE)
Module that streams a file from the PC to the target over the tuning
interface. The data is transfered block-by-block from the PC to the
target.
Arguments:
NAME - name of the module.
TRANSFERSIZE - size of the transfer buffer, in 32-bit words. The
data is transferred from MATLAB down to the target one block at a
time using this buffer.
CIRBUFSIZE - size of the internal circular buffer, in 32-bit words.
The data is copied from the transfer buffer to the circular
buffer, and then from the circular buffer to output.
Copyright (c) 2026 DSP Concepts, Inc.