User`s guide
To Wave Device
5-445
Buffering
Because the audio device generates real-time audio output, Simulink must 
maintain a continuous flow of data to the device throughout the simulation. 
Delays in passing data to the audio hardware can result in hardware errors or 
distortion of the output. This means that the To Wave Device block must in 
principle supply data to the audio hardware as quickly as the hardware reads 
the data. However, the To Wave Device block often cannot match the 
throughput rate of the audio hardware, especially when the simulation is 
running from within Simulink rather than as generated code. (Simulink 
execution speed routinely varies during the simulation as the host operating 
system services other processes.) The block must therefore rely on a buffering 
strategy to ensure that signal data is accessible to the hardware on demand.
At the start of the simulation, the To Wave Device block writes T
d
 seconds 
worth of signal data to the device (hardware) buffer, where T
d
 is specified by 
the 
Initial output delay parameter. When this initial data is loaded into the 
buffer, the audio device begins processing the buffered data, and continues at 
a constant rate until the buffer empties. The size of the buffer, T
b
, is specified 
by the 
Queue duration parameter. As the audio device reads data from the 
front of the buffer, the To Wave Device block continues appending inputs to the 
back of the buffer at the rate they are received.
The following figure shows an audio signal with 8 samples per frame. The 
buffer of the sound board has a five-frame capacity, not fully used at the instant 
shown. (If the signal sample rate was 8kHz, for instance, this small buffer 
could hold approximately 0.005 seconds of data.)
If the simulation throughput rate is higher than the hardware throughput 
rate, the buffer remains at a constant level throughout the simulation. If 
necessary, the To Wave Device block buffers inputs until space becomes 
available in the hardware buffer (i.e., data is not thrown away). More typically, 
board
Hardware buffer with 
5-frame ca
p
acit
y
Simu
l
in
k
 execution rate varies Har
d
ware execution rate is constant
no delays
Simulation delay










