User`s guide
From Wave Device
5-218
The Sample Width (bits) parameter specifies the number of bits used to
represent the signal samples read by the audio device. Two settings are
available:
•
8 – allocates 8 bits to each sample, allowing a resolution of 256 levels
•
16 – allocates 16 bits to each sample, allowing a resolution of 65536 levels
The 16-bit sample width setting requires more memory but yields better
fidelity. The output from the block is independent of the
Sample Width (bits)
setting, and is always double precision.
Buffering
Since the audio device accepts real-time audio input, Simulink must read a
continuous stream of data from the device throughout the simulation. Delays
in reading data from the audio hardware can result in hardware errors or
distortion of the signal. This means that the From Wave Device block must in
principle read data from the audio hardware as quickly as the hardware itself
acquires the signal. However, the 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 operations are generally
slower than comparable hardware operations, and 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 can be read on schedule without losing samples.
At the start of the simulation, the audio device begins writing the input data to
a (hardware) buffer with a capacity of T
b
seconds. The From Wave Device block
immediately begins pulling the earliest samples off the buffer (first in, first out)
and collecting them in length-M frames for output. As the audio device
continues to append inputs to the bottom of the buffer, the From Wave Device
block continues to pull inputs off the top of the buffer at the best possible rate.
The following figure shows an audio signal being acquired and output with a
frame size of 8 samples. The buffer of the sound board is approaching its
five-frame capacity at the instant shown, which means that the hardware is
adding samples to the buffer more rapidly than the block is pulling them off. (If