-
Notifications
You must be signed in to change notification settings - Fork 8
Audio Codecs
I'm currently interested in using Audio Codecs by various MCUs and to find what are advantages and disadvantages.
What is Audio codec?
- It is digital to analog and analog to digital audio interface.
- when you play audio you stream digital Audio data using suitable protocol (for example I2S) and codec will filter and convert and output them as Analog. Many codecs have even Power Audio amplifier to directly connect headphones or small speaker (typical usage case on mobile devices)
- when you record audio it goes opposite way: analog input is processed by amplifier (limiter or automatic gain amplifier) filtered and converted to digital data. These data are streamed back to CPU using suitable interface/protocol (I2S etc).
Please note that today codecs are very sophisticated:
- they automatically oversample signal (you use for example sample rate 44kHz but codec internally multiply it to 128kHz and interpolate to smooth output and make it sounds better)
- they have various filters (some including equalizers or wind filter on microphone input)
- for both output and input they have soft limiter to avoid hard clipping and distortion
- for analog input codecs offer boost amplifiers, automatic gain amplifier and limiter for best processing of microphone input
First popular codec was Intel AC97 for integrated PC Sound cards. See for example https://en.wikipedia.org/wiki/AC%2797. Please note that AC97 used older digital interface called AC-Link. Today most prevalent is I2S or similar (DSP/PCM and others).
So far I tested:
- dsPIC33CH (16-bit CPU with DSP extensions) + mono codec WM8510
- project page: https://github.com/hpaluch/dm330011-audio-intro
- PIC32MX470 (32-bit MIPS32 M4K CPU) + stereo audio codec WM8904
- project page: https://github.com/hpaluch/PIC32MX470-Curiosity
However I plan to also test 32F769IDISCOVERY:
- board homepage: https://www.st.com/en/evaluation-tools/32f769idiscovery.html
- CPU STM32F769NI
- Cortex-M7
- board document https://www.st.com/resource/en/data_brief/32f769idiscovery.pdf does not include Codec type but we can find:
- download and unpack firmware: https://www.st.com/en/embedded-software/stm32cubef7.html
- here is smallest Audio example:
STM32Cube_FW_F7_V1.17.0\Projects\STM32F769I-Discovery\Examples\BSP\Src\audio_play.c
- BSP Audio routines are in
STM32Cube_FW_F7_V1.17.0\Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_audio.h
- where we can find line:
/* Include audio component Driver */ #include "../Components/wm8994/wm8994.h"
- finally we can find
STM32Cube_FW_F7_V1.17.0\Drivers\BSP\Components\wm8994\wm8994.c
- so the codec should be WM8994
- also we can find this project on GitHub: https://github.com/STMicroelectronics/stm32-wm8994
To understand STM32 + WM8994 you have to study at least under STM32Cube_FW_F7_V1.17.0
:
Projects\STM32F769I-Discovery\Examples\BSP\Src\audio_play.c
Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery.c
Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery.h
Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_audio.c
Drivers\BSP\STM32F769I-Discovery\stm32f769i_discovery_audio.h
Drivers\BSP\Components\wm8994\wm8994.c
Drivers\BSP\Components\wm8994\wm8994.h
Also here is really interesting page:
- https://wiki.st.com/stm32mpu/wiki/Audio_codecs_hardware_components
- however these are for STM32MP Series which are Cortex-A (highest Cortex series used mainly for Linux these days).
Copyright © Henryk Paluch. All rights reserved.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License