A very simple example showing how to play mp3 files on the ESP32

Overview

build status

ESP32 MP3 Player

This repo contains a simple demonstration of how to play an MP3 file on the ESP32.

You can configure the output to be either an I2S device or the built-in DAC to output the audio to a set of headphones or an analogue amplifier.

Be aware that the DAC is extremely noisy so at low vollume levels most of the sound will be dominated by noise. It may be possible to reduce the noise by using a low pass filter on the output.

In theory you should have a DC blocking capacitor between the output and headphones, but I found this to cause a large amount of noise.

When using the DAC the left channel will be output on GPIO26 and the right channel will be output on GPIO25.

I've added an optional volume control. You can connect a potentiometer between 3.3v and ground and connect it to one of the ADC channels.

Make sure you upload the filesystem as the sample mp3 file is stored on SPIFFS.

Configuration

All the configuration settings are in the config.h file.

// comment this line out if you want to use the built-in DAC
#define USE_I2S

// speaker settings - if using I2S
#define I2S_SPEAKER_SERIAL_CLOCK GPIO_NUM_19
#define I2S_SPEAKER_LEFT_RIGHT_CLOCK GPIO_NUM_21
#define I2S_SPEAKER_SERIAL_DATA GPIO_NUM_18
#define I2S_SPEAKDER_SD_PIN GPIO_NUM_5

// volume control - if required - comment this out if you don't want it
#define VOLUME_CONTROL ADC1_CHANNEL_7

// button - GPIO 0 is the built in button on most dev boards
#define GPIO_BUTTON GPIO_NUM_0
You might also like...
SoundMixr is a simple audio mixer for ASIO devices, but specifically made for SAR (http://sar.audio/), it sees all the channels in the ASIO device and shows them with the option to route any input to any output. Each channel also has a mute, mono, stereo pan and volume parameter. This is simple beeper engine for the ZX Spectrum 48K
This is simple beeper engine for the ZX Spectrum 48K

Beeper engine This is simple beeper engine for the ZX Spectrum 48K (or later), designed to be run from an interrupt handler.

simple audio mixer for native and web

🔊 auph 🎧 Trivial audio mixer API for native and web targets. Online Demo ⚠️ Work in progress! API is constantly changing. The native playback at the

A simple CLI to extract & save artwork of a 🎵 music/audio file.
A simple CLI to extract & save artwork of a 🎵 music/audio file.

artwork-extractor A simple CLI to extract & save artwork of a 🎵 music/audio file. Usage Dependencies MediaInfoLib On Debian based distros, one may in

SSMLSDL - Simple Sound Manipulation Library, Based on SDL and LIBWAV.

SSM-lib SSMLSDL - Simple Sound Manipulation Library, Based on SDL and LIBWAV. This library is open source and free software. It's aims to provide YOU,

A simple and easy-to-use audio library based on miniaudio

raudio A simple and easy-to-use audio library based on miniaudio raudio forks from raylib.audio module to become an standalone library. Actually, it w

A simple and easy-to-use fx sounds generator, based on the amazing Dr.Petter's sfxr
A simple and easy-to-use fx sounds generator, based on the amazing Dr.Petter's sfxr

rFXGen A simple and easy-to-use fx sounds generator, based on the amazing Dr.Petter's sfxr. rFXGen can be used for free as a WebAssembly online tool a

ASS: Audio Stupidly Simple

A single header library for audio decoding and playback

✔️The smallest header-only GUI library(4 KLOC) for all platforms
✔️The smallest header-only GUI library(4 KLOC) for all platforms

Welcome to GUI-lite The smallest header-only GUI library (4 KLOC) for all platforms. 中文 Lightweight ✂️ Small: 4,000+ lines of C++ code, zero dependenc

designed for debug Espressif's ESP series chips, include ESP32/ESP32-S2/ESP32-C3/ESP32-S3...
designed for debug Espressif's ESP series chips, include ESP32/ESP32-S2/ESP32-C3/ESP32-S3...

ESPLink 中文 ESPLink Introduce Features Pin Description esplink-tool Product Link Reference ESPLink Introduce ESPLink is a debug tool build for Expressi

A simple example showing how to render a video with libvlc + raylib.
A simple example showing how to render a video with libvlc + raylib.

Hey! I bet you have been trying to render and control a video with raylib for a long long time. Don't you think you should at least buy me a beer? Wha

A modern-day Boss Key software tool. Switch instantly from work to play & play to work with Bosky.

Bosky By: Seanpm2001, Bosky-dev Et; Al. Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrika

A crude untested example showing how to retrieve and display images from multiple cameras with OpenCV and wxWidgets.

About wxOpenCVCameras is a crude untested example of how to retrieve and display images from multiple cameras, using OpenCV to grab images from a came

A couple of demos showing how to use the Ultra Low Power coprocessor on the ESP32
A couple of demos showing how to use the Ultra Low Power coprocessor on the ESP32

ESP32 Ultra Low Power (ULP) coprocessor You can watch a video explanation of this code here This repo contains two demo project: ulp-gpio Shows you ho

ESP32-Skid-Steer - Bruder Catepillar Skid Steer model converted to RC, controlled by an ESP32 with 2 analog joysticks and a receiver that is an ESP32 on the model.
ESP32-Skid-Steer - Bruder Catepillar Skid Steer model converted to RC, controlled by an ESP32 with 2 analog joysticks and a receiver that is an ESP32 on the model.

ESP32-Skid-Steer Bruder Catepillar Skid Steer model converted to RC, controlled by an ESP32 with 2 analog joysticks and a receiver that is an ESP32 on

Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

MP3 Player/Organizer

I ♡ Music I ♡ Music is an MP3 player and organizer. It is designed for handling collections of albums in MP3 format, and it is very visual, attempting

Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele
Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele

Wortuhr_ESP8266 Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele, Webzugriff So

Comments
  • Terrible noise when using built-in DAC

    Terrible noise when using built-in DAC

    Hi it's me again, I wanted to look into using the DAC for output, but the output is terribly noisy. The song is almost inaudible. I have connected just the right channel using pin 25. I followed your schematic and added a capacitor of 100 uF with low ESR, and an resistor of 600 ohms. This gives terrible noise, omitting one or all of these components, the noise is just the same. I added an audio sample (in zip because of github policy), as you can hear, it sounds horrid and the sample in your video sounded a lot better. WhatsApp Audio 2021-12-04 at 11.33.49.zip

    What did I do wrong? my config.h

    #include <freertos/FreeRTOS.h>
    #include <driver/i2s.h>
    
    // comment this out if you want to use the internal DAC
    // #define USE_I2S
    
    // speaker settings - if using I2S
    #define I2S_SPEAKER_SERIAL_CLOCK GPIO_NUM_19
    #define I2S_SPEAKER_LEFT_RIGHT_CLOCK GPIO_NUM_21
    #define I2S_SPEAKER_SERIAL_DATA GPIO_NUM_18
    #define I2S_SPEAKDER_SD_PIN GPIO_NUM_5
    
    // volume control - if required
    // #define VOLUME_CONTROL ADC1_CHANNEL_7
    
    // button - GPIO 0 is the built in button on most dev boards
    #define GPIO_BUTTON GPIO_NUM_0
    
    // i2s speaker pins definition
    extern i2s_pin_config_t i2s_speaker_pins;
    

    That's the only thing I changed next to the upload port

    opened by Bartvelp 3
  • no audio with esp-idf 4.4.1 when using the internal DAC

    no audio with esp-idf 4.4.1 when using the internal DAC

    For the internal DAC example to work, lib/audio_output/src/DACOutput.cpp line 12 needs to be changed to:

        .communication_format = I2S_COMM_FORMAT_STAND_MSB,
    

    Assuming that this was working in previous releases, it looks like esp-idf changed its behaviour and now you need to explicitly tell the i2s to use the 8 most significant bits from the 16 bits per sample? Maybe..

    opened by dlavrantonis 1
  • Incompletely decoded data

    Incompletely decoded data

    Good afternoon. I'm assuming you're cutting off samples too early here. After all, info.frame_bytes is read from the buffer input_buf about 365-366 bytes. Thus, you cut off the sound without reading input_buf.len()-info.frame_bytes => BUFFER_SIZE=1024 - 365 = 659 bytes i.e. a couple more decoded samples you cut off

    opened by Jekahome 0
Owner
atomic14
atomic14
MP3 Player/Organizer

I ♡ Music I ♡ Music is an MP3 player and organizer. It is designed for handling collections of albums in MP3 format, and it is very visual, attempting

Mattias Gustavsson 26 Sep 10, 2022
Cross platform C++11 library for decoding audio (mp3, wav, ogg, opus, flac, etc)

Libnyquist is a small C++11 library for reading sampled audio data from disk or memory. It is intended to be used an audio loading frontend for games, audio sequencers, music players, and more.

Dimitri Diakopoulos 414 Sep 26, 2022
A simple C++ library for reading and writing audio files.

AudioFile A simple header-only C++ library for reading and writing audio files. Current supported formats: WAV AIFF Author AudioFile is written and ma

Adam Stark 651 Sep 30, 2022
Example for transmit video + audio to tv via hackRF

Этот код может передавать звук и изображение на телевизор через hackRF В этом проекте использовался код из следующих репозиториев: https://github.com/

null 9 Sep 27, 2022
A C library for reading and writing sound files containing sampled audio data.

libsndfile libsndfile is a C library for reading and writing files containing sampled audio data. Authors The libsndfile project was originally develo

null 1k Sep 28, 2022
LibMEI is a C++ library for reading and writing MEI files

C++ library and Python bindings for the Music Encoding Initiative format

Distributed Digital Music Archives and Libraries Lab 53 Aug 31, 2022
straightforward CLI tool for spectral analysis of sound files

dowser dowser is (presently) a quick and simple low-level utility for performing spectral analysis of sound files. usage dowser

ezra buchla 13 Aug 9, 2022
A C library to read standard MIDI files.

A C library to read standard MIDI files.

Philip Bennefall 20 Sep 27, 2022
SimplE Lossless Audio

SELA SimplE Lossless Audio A lossless audio codec which aims to be as simple as possible while still having good enough compression ratios. Code Quali

Ratul Saha 207 Sep 13, 2022
An audio mixer that supports various file formats for Simple Directmedia Layer.

An audio mixer that supports various file formats for Simple Directmedia Layer.

Simple Directmedia Layer 163 Sep 26, 2022