ALSA Audio Capture
Capture audio from sound card using ALSA
Add-On Required: This feature requires the Simulink Support Package for Raspberry Pi Hardware add-on.
Libraries:
Simulink Support Package for Raspberry Pi Hardware /
Audio and Video
Description
The ALSA Audio Capture block reads audio data from the audio input device connected to the hardware. The block uses the Advanced Linux Sound Architecture (ALSA) driver framework to read audio data.
The block outputs the audio data as an N-by-C matrix, where N is the samples per audio channel, and C is the number of channels supported by the audio device. Specify the values for N and C in the Samples per frame (N) and Number of channels (C) parameters, respectively.
Note
To use the ALSA Audio Capture block with audio devices that support more than two channels, you must have an Audio Toolbox™ license.
In the Simulink® model, you can set the ALSA Audio Capture block as the source of the scheduler interrupt for the Raspberry Pi® hardware. For more information, see Scheduler options.
Algorithm
Consider a Simulink model that includes an ALSA Audio Capture block and an ALSA Audio Playback block. At each sample time, the ALSA Audio Capture reads stereo audio data from the microphone connected to the audio input connector of the hardware. The block outputs data as a 3-by-2 matrix. The ALSA Audio Playback block accepts the audio matrix and sends audio to the headphones connected to the audio output jack of the hardware.
The ALSA Audio Capture block determines the sample time (Ts) from the samples per audio channel (N) and sampling frequency (Fs).
Ts = N / Fs
For example, if N is 4410 samples and Fs is 44,100 Hz, the block sample time is 4410/44,100 = 0.1 seconds.
N is the number of samples per audio channel specified in the Number of channels (C) parameter. Fs is the sampling frequency of audio data specified in the Audio sampling frequency (Hz) parameter.
Ports
Output
Parameters
Version History
Introduced in R2013a