Audio Input
Read audio sample from audio devices on STMicroelectronics STM32F746G/STM32F769I–Discovery board
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 /
STM32F746G-Discovery
Embedded Coder Support Package for STMicroelectronics STM32 Processors /
STM32F769I-Discovery
Description
The Audio Input block reads audio samples from the audio device (Microphone, Line In) connected to the processor on the STM32F746G/STM32F769I–Discovery™ boards. The audio samples are either in Pulse Density Modulation (PDM) format or Pulse Code Modulated (PCM) format. The format of the audio samples depends on the device from which the block acquires audio.
The block emits PCM audio frames. For STM32F746G, these frames are
[Nx2]
int16
matrix. For STM32F769I, these frames are
[Nx2]
for Line In input, and [Nx2]
or
[Nx4]
for Microphone input, depending on the number of channels
selected. N
is the number of samples per frame, and
2
and 4
are the number of audio channels per
frame.
You can read audio samples at different rates, such as 8 kHz, 11 kHz, 16 kHz, 22 kHz, 32 kHz, 44 kHz, 48 kHz, 96 kHz, and 192 kHz (STM32F746G only), with different frame sizes.
Using the parameters of this block, you specify the device from which you acquire audio. For STM32F746G, you can also specify the volume level at which the block emits audio frames.
The output of this block connects to audio devices such as headphones or speakers.
Read Audio from Microphone or LineIn
The STM32F746G/STM32F769I–Discovery board acquires audio from either of the two audio devices, Dual MEMS Microphones (MP34DT01), or Line In that connect to the board.
The dual MEMS microphones (MP34DT01) on the STM32F746G–Discovery board outputs a PDM signal, which is then sent to the WM8994 codec. The WM8994 codec converts the PDM signal to 16-bit PCM format and sends it to the ARM® Cortex® M7 processor.
The two dual MEMS microphones on the STM32F769I–Discovery board outputs PDM signals, which are then sent to the digital filter for sigma delta modulation (DFSDM) peripheral. The DFSDM peripheral converts the PDM signals to 16-bit PCM format and sends it to the ARM Cortex M7 processor.
LineIn outputs a PCM signal. The output signal is sent to the WM8994 codec, which is then sent to the ARM Cortex M7 processor. These frames are then sent to the connected audio devices.
Audio data between audio devices, WM8994 codec, and the ARM Cortex M7 processor are transferred by using I2S line.
Note
The 16-bit PCM audio frames from LineIn, which are streamed through the WM8994 codec and ARM Cortex M7 processor, do not undergo any conversion.
Read Audio Data with Double Buffering
The Audio Input block uses a double buffering mechanism to read the audio data from the audio device.
With double buffering, the DMA uses one buffer to read an audio PCM signal from the audio device while the other buffer sends audio frames to the audio processing algorithm. When the audio algorithm uses the buffer, this mechanism helps to prevent overwriting of the buffer.
With the double buffering mechanism in the Audio Input block:
In the first iteration, when the Audio In buffer1 sends the data for audio processing, the DMA fills Audio In buffer0.
In the first iteration, the Audio In buffer1 does not contain the audio samples. Therefore, the audio samples from the Audio Input block are delayed by one audio frame.
After the DMA completes filling Audio In buffer0, an interrupt is triggered.
In the second iteration, when the Audio In buffer0 sends the data for audio processing, the DMA fills Audio In buffer1.
Examples
Ports
Output
Parameters
More About
Extended Capabilities
Version History
Introduced in R2016b