Loud ESP

Portable, open-source, ESP32-powered audio-development platform with a touchscreen and support for Bluetooth & Wi-Fi connectivity

Mar 22, 2023

Project update 3 of 7

Using Loud-ESP with Espressif's Audio Development Framework

by Andriy

Loud-ESP is not the first audio development board based on the ESP32. In fact, Espressif themselves developed a line of audio development kits that utilize I2S capabilities together with external DACs, DSPs, and power amplifiers. Those are advanced kits aimed for advanced projects. So advanced, in fact, that Espressif developed the ESP-ADF (Audio Development Framework) to work side by side with ESP-IDF.

It lets you abstract away underlying hardware and it’s capabilities from the actual application logic. Also, it adds support for common audio development techniques, such as audio pipelines, streams, and events.

All in all it is quite a complex framework with a lot of possibilities. It is not very well documented (as per my taste), but has a good list of examples to get started with.

For this week’s update, I’ve added basic support for Loud-ESP boards and I’m going to show you how to run a basic play-mp3-control example.


First of all, you need to pull the code from my fork of ESP-ADF. It has board definitions for Loud-ESP board (and AI-Thinker ADK as a bonus). It is important to pull the code with all the submodules, mainly because ADF lags behind IDF by considerable margin (it runs on v4.4 of IDF at the moment of writing)

git clone https://github.com/sonocotta/esp-adf 
cd esp-adf 
git submodule update --init --recursive  ## This will take a while, and pull whole ESP-IDF with train of dependencies

Next, you’ll need to configure ESP-IDF, which comes as a submodule. Don’t worry if you already have IDF installed, it can run side by side with other versions.

cd esp-idf
./install.sh # Again, it will take a while to install all the toolchains, related apps, and to configure the  Python environment

Running the play-mp3-control example

Now let’s run a basic example. First, you’ll need to switch to the examples/get-started/play_mp3_control folder.

As with other ESP-IDF projects, first you’ll need to activate the dev environment by running the $IDF_PATH/export.sh script. There are few ways to do this, but my favorite is to add simple activation shortcuts to the ~/.bashrc file.

if [ -d "$HOME/storage/sdk/esp-adf/esp-idf" ]
    alias ga44='IDF_PATH=$HOME/storage/sdk/esp-adf/esp-idf; . $IDF_PATH/export.sh'
    alias i='$IDF_PATH/tools/idf.py'
    echo "Error: Directory storage/sdk/esp-adf/esp-idf does not exist."

Now you can activate IDF by running ga44 in the folder of your choice.

Next, we need to switch audio HAL by running an idf.py menuconfig command, or using the alias i menuconfig. You can then switch boards in the Audio HAL section

The rest is fairly simple: run i build flash monitor and, after minute or two of heavy building, you’ll enjoy your mp3 playing from your speakers

I (0) cpu_start: Starting scheduler on APP CPU.
I (535) PLAY_FLASH_MP3_CONTROL: [ 1 ] Start audio codec chip
I (545) PLAY_FLASH_MP3_CONTROL: [ 2 ] Create audio pipeline, add all elements to pipeline, and subscribe pipeline event
I (555) PLAY_FLASH_MP3_CONTROL: [2.1] Create mp3 decoder to decode mp3 file and set custom read callback
I (565) PLAY_FLASH_MP3_CONTROL: [2.2] Create i2s stream to write data to codec chip
I (575) PLAY_FLASH_MP3_CONTROL: [2.3] Register all elements to audio pipeline
I (575) PLAY_FLASH_MP3_CONTROL: [2.4] Link it together [mp3_music_read_cb]-->mp3_decoder-->i2s_stream-->[codec_chip]
I (595) PLAY_FLASH_MP3_CONTROL: [ 3 ] Initialize peripherals
I (595) PLAY_FLASH_MP3_CONTROL: [3.1] Initialize keys on board
I (605) PLAY_FLASH_MP3_CONTROL: [ 4 ] Set up  event listener
I (605) PLAY_FLASH_MP3_CONTROL: [4.1] Listening event from all elements of pipeline
I (615) PLAY_FLASH_MP3_CONTROL: [4.2] Listening event from peripherals
W (625) PLAY_FLASH_MP3_CONTROL: [ 5 ] Tap touch buttons to control music player:
W (635) PLAY_FLASH_MP3_CONTROL:       [Play] to start, pause and resume, [Set] to stop.
W (645) PLAY_FLASH_MP3_CONTROL:       [Vol-] or [Vol+] to adjust volume.
I (645) PLAY_FLASH_MP3_CONTROL: [ 5.1 ] Start audio_pipeline
I (665) PLAY_FLASH_MP3_CONTROL: [ * ] Receive music info from mp3 decoder, sample_rates=8000, bits=16, ch=2

Other Examples

There are quite a few more examples to have fun with. Naturally, you cannot run those that depend on a particular input device (like line-in or mic), but plenty remain for you to play with.

Sign up to receive future updates for Loud ESP.

Subscribe to the Crowd Supply newsletter, highlighting the latest creators and projects