I2S Audio Out
Add-On Required: This feature requires the Embedded Coder Support Package for STMicroelectronics STM32 Processors add-on.
Libraries:
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F2xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F3xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F4xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F7xx Based Boards
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32G4xx Based Boards
Description
The I2S Audio Out block sends a stream of data to the audio output connector. The block writes the processed audio data to the audio device connected to the processor on the STM32F4xx based board. You can send the audio samples at different rates such as 16kHz, 32kHz etc. with different frame sizes.
The input port accepts either int16
or
int32
audio frames in [Nx2] format for
Stereo.
You can play only stereo [Nx2] audio frames on this block.
Note
You cannot play [1x1] audio samples on this block as the frame requires at least two samples.
Send Processed Audio Samples Using Double Buffering
The Audio Out block uses a double buffering mechanism to send data to the audio device.
With double buffering, one buffer is used by the DMA to transfer audio frame from the processor to the audio device while the other buffer is used to receive the processed audio frame from your audio algorithm. Doing so helps to prevent overwriting the buffer while sending the data to the audio device.
When you send an audio frame of length N samples
,
the block creates two buffers of length N
samples.
The following describes the double buffering mechanism in the Audio Out block.
In the first iteration, when the processed audio signal is sent to the audio device from ‘Audio out buffer1’, the ‘Audio out buffer0’ is filled with audio signal from the audio processing algorithm.
In the first iteration, the ‘Audio out buffer1’ does not contain the audio samples. Therefore, the audio samples from the Audio Out block are delayed by one audio frame. If your model has Mic In and the Audio Out blocks, then there is a time delay of two audio frames as the Mic In block also uses the same double buffering technique.
After the DMA completes sending out the processed data from ‘Audio out buffer1’, an interrupt is generated.
In the second iteration, when the processed audio signal is sent out to the audio device from Audio out buffer0, the ‘Audio out buffer1’ is filled with the audio data from the audio processing algorithm.
Examples
Ports
Input
Parameters
Extended Capabilities
Version History
Introduced in R2023a