I am trying to add the opus codec to my project, using esp32 with idf framework, i added line “lib_deps = GitHub - xiph/opus: Modern audio compression for the internet.”
However I still cannot build, can someone point me in the right direction?
Hold on a second, the ESP-ADF (audio framework) which is just a bunch of components on top of ESP-IDF, already has an official Opus decoder and encoder.
https://docs.espressif.com/projects/esp-adf/en/latest/api-reference/codecs/opus_decoder.html
ESP ADF only supports opus decode not encode. I want to see if it is possible to port the raw opus code into my project, without having to rely on others libraries. Opus has its own cmake file already, I’m curious as to how I can get it to build with the rest of the project. Obviously it has its own build flags which can be changed too
https://github.com/espressif/esp-adf-libs/blob/master/esp_codec/include/codec/opus_encoder.h exists equally.
Two ways:
- Build a precompiled library for Opus using their CMake build system, telling it the compiler you’re using (
xtensa-esp32-elf-gcc
) etc., then copy only the header files +libopus.a
in the project and use it - Tell PlatformIO how to build the Opus library in the native SCons build system by forking the opus library and adding the appropriate library.json to it. PlatformIO, and also SCons, does not natively know how to just build a CMake project like that, so you have to tell it what source files to use, what compiler settings to use, trigger the generation of missing files that the CMake might generate, etc.
Thank you, I did not know they included opus encoder in esp adf. How would i integrate esp adf into my project then?
Well, a starting point would be to try and port over the clean recording_to_sdcard_example.c example since it showcases a usage of opus_encoder.h
.
Start with the ESP-IDF base example espidf-hello-world, then copy-paste all components from a recursively-git-cloned ESP-ADF repo’s components/
folder into that project’s components
folder (docs). Then all the original example’s relevent files (CMake*, main/
folder, sdkconfig*, KConfig) should be copied as well.