schreibfaul1 / esp32-audioi2s Goto Github PK
View Code? Open in Web Editor NEWPlay mp3 files from SD via I2S
License: GNU General Public License v3.0
Play mp3 files from SD via I2S
License: GNU General Public License v3.0
Hallo,
I think it is not really a problem with the library. Maybe something with the wiring. But I get only sound while touching the BCLK PIN with something conductive. I thing there is a need of a capacitive load?
I use MAX98357A Breakout board (Marking AKK NRB).
ESP32 Board ist a Wemos LOLIN32.
Maybe someone can provide a solution for this. Thank you.
I would like to ask, if it is possible to add FLAC support to the library
Hi. It's me. Again.
How can I find out information about a web stream?
Information is needed: track name, bit rate, bad or good url address, buffer fill percentage, is the stream ready to play or not. I want to display information on the screen and automatically jump to the next station if the current station has a bad URL.
The necessary information is displayed in the port monitor, but I do not know how to get it.
Could you extend connecttoSD to the more universal method for using SPIFFS and SD in the same time?
bool Audio::connecttoFS(fs::FS &fs, String sdfile){
...
//fs::FS &fs=SD;
Please put file I2Saudio.ino in folder I2Saudio
examples --> I2Saudio --> I2Saudio.ino
When pausing audio, I get some clicking noise for a short period of time. This can be avoided by flushing the buffer just like it is done in stopSong(). Hence I suggest to change pauseResume() like this:
bool Audio::pauseResume()
{
bool retVal = false;
if(m_f_localfile || m_f_webstream)
{
m_f_running = !m_f_running;
retVal = true;
if(!m_f_running) {
i2s_zero_dma_buffer((i2s_port_t)m_i2s_num);
memset(m_outBuff, 0, sizeof(m_outBuff)); //Clear OutputBuffer
}
}
return retVal;
}
Btw: I also found it useful to have functions like pause() and resume() separately...
Thanks for your work! It's really awesome. However, i often got a buffer underrun and i'm thinking if should be possible to use an external RAM via SPI like 23LC1024 for buffering
Hi,
I was searching for high quality 320kbps stations and i found some with periodically interrupted sound.
I found other 320kbps stations which plays well, so it is not ESP32 performance problem. I checked and it is not PSRAM buffer problem.
I'm wondering why some stations didnt plays correctly?
I loked at ICY HTTP response headers but I didin't found anything special...
Maybe problematic stations have different mpeg format and MP3 decoder cannot handle it?
Do you have any idea what is wrong here?
thanks, wk
Here are examples:
NOT working properly:
// 320kbps
http://listen.radiogora.ru:8000/electro320
http://play.organlive.com:7000/320
// 128kbps
http://thecheese.ddns.net:8010/listen.pls
Working ok:
//320kbps
https://mediaserv30.live-streams.nl:18086
http://www.partyviberadio.com:8010/listen.pls
http://www.partyviberadio.com:8000/listen.pls
Not OK station header:
HTTP/1.0 200 OK
icy-notice1:
This stream requires Winamp
icy-notice2:SHOUTcast DNAS/win32 v2.6.0.750
Accept-Ranges:none
Access-Control-Allow-Origin:*
Cache-Control:no-cache,no-store,must-revalidate,max-age=0
Connection:close
icy-name:Organlive.com
icy-genre:classical
icy-br:320
icy-sr:44100
icy-url:http://www.organlive.com
icy-pub:1
content-type:audio/mpeg
icy-metaint:16384
X-Clacks-Overhead:GNU Terry Pratchett
onNewStation: Organlive.com
OK station header:
HTTP/1.0 200 OK
Server: Icecast acc-0.9.10.25 2.4.3-backportCVE-2018-18820
Date: Wed, 02 Sep 2020 10:49:37 GMT
Content-Type: audio/mpeg
Cache-Control: no-cache
Expires: Mon, 26 Jul 1997 05:00:00 GMT
Pragma: no-cache
Access-Control-Allow-Origin: *
icy-br:320
ice-audio-info: channels=2;samplerate=44100;bitrate=320
icy-br:320
icy-name:RadioMonster.FM - Tophits
icy-pub:1
icy-metaint:16000
Thanks for this project. It helped me. a lot and my project is nearly coming to an end.
I'm using a M5Stack with the Node-Module and would like to play some tones from the SD card.
How do I use the audio.connecttoSD function?
At the moment I have only the following line in place
audio.connecttoSD("/a001.mp3");
`
But I can hear nothing and I'm not sure if the file gets played.
Thanks in advance for any advice.
Best regards.
Hi,
Got this up and running first time (Great work - thanks). My only problem is that it's playing at max volume (and distorted as so loud) all the time, I tried setting the audio.setVolume() to less than 21 but all values were max volume apart from 0, which gave no sound. Any pointers? Thanks in advance. I'm using the PCM1502a.
Please ignore - sorted. I'd not pulled FMT low, it was floating high and thus the distortion etc.
Hi,
First of all awesome job with this library. I did have a bit of a pain installing it within Arduino IDE and had to create a separate folder with all the library files in for it to work.
Now works audio is really good, I am using a UD1344a DAC. When listening to a stream from time to time I get a brrrrrrrrrrr sound then audio resumes, seems possibly like a buffer issue. I have increased DMA-buffer from 64 to 128 and this has made no difference.
Any ideas on how this could be fixed, would make an awesome internet radio otherwise.
Big thanks
Dans
I can't get ESP32-audioI2S working on the TTGO T7_V1.3 board.
It is the same board as this one: https://www.youtube.com/watch?v=LAN7mk4dFG8
It does run on most of my WEMOS/LOLIN D1 mini32 clone boards which share the same pinout.
Just a lot of static/clipping running this sketch on the TTGO:
#include <Audio.h> /* https://github.com/schreibfaul1/ESP32-audioI2S */
#define I2S_BCK 21
#define I2S_WS 17
#define I2S_DOUT 22
Audio audio;
void setup() {
audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT);
WiFi.begin("wifi", "psk");
while (!WiFi.isConnected()) {
delay(10);
}
ESP_LOGI(TAG, "Connected");
ESP_LOGI(TAG, "Starting MP3...\n");
audio.connecttohost("http://icecast.omroep.nl/3fm-bb-mp3");
audio.setVolume(5); // 0...21
}
void loop() {
audio.loop();
delay(1);
}
Anybody know how to solve this? I tried all settings in the Arduino IDE I think.
Using Arduino 1.8.13 and UDA1334A boards.
I integrated your lib into a port of the Tonuino-project (code not yet online) using ESP32. However, I recognized the first webstream is no problem, but coming up with a new one (after calling audio.stopSong();
let to the problem, that no further webclient-connection is available (I'm running MQTT-connections in parallel). However, I checked your code and discovered
clientsecure.stop(); clientsecure.flush(); // release memory
in Audio.cpp:103. Is there a reason why you don't reset unsecured connectons as well? Anyway, I added
client.stop(); client.flush(); // release memory
and now it works for me.
Inspired by the project "Tonuino" I'm actually about to port (so to say) this stuff to ESP32 in order to have wifi-support. Or at least I'm trying to do so :-) So I played around a bit with your lib which is working absolutely fine for mp3-webstreams. However, playing files locally from uSD basically works but leads to pretty distorted sound (tried two mp3-files @128 kBps and your mp3-file provided as well).
Set-up: ESP32 devboard (wroom-32)
I2S-DAC: Adafruit MAX98357A
Any suggestions?
I have created an effects box to playback short sound effect files for use in radio productions. This box plays a sound clip when an associated button is pressed on the box. I am using a MAX98357A codec to drive the speaker and a ESP32-WROOM-32 board.
The issue I am experiencing is that sometimes the audio file is not played when the associated button is pressed and when I press the same button again it does playback. Additionally sometimes when I press a button and get no playback I then get this clip added to the next one played, especially if it a longer one.
I have the 'audio_info' enabled so I can see what is happening and the below output is shown when the button is pressed but no audio is generated on the speaker:
info Reading file: click.mp3
info ID3 version=3
info ID3 framesSize=89
info ID3 normal frames
info stream ready
info syncword found at pos 0
info Channels=2
info SampleRate=44100
info BitsPerSample=16
info Bitrate=320000
info End of mp3file click.mp3
If I press the button again audio is then generated on the speaker with the same information displayed above.
Could this be a buffer problem due to the clips being so short and possibility the buffer not being flushed totally so part of a preceding audio clip could be left in the buffer when the next one is played.
I have attached a couple of the clips to test, the click.mp3 being the one that produces the worst problem as its really short.
David
clips.zip
Great library! I am having issues when connecting to https (port 443). The stream gets interrupted every 30 sec or so. Any insights or possible solutions are appreciated. I tested this with demo code (I2Saudio.ino). Example link: https://arabellaaustropop.stream.arabella.at/arabellaaustropop
If I want to play a mp3 file with 128k bitrate it wont play. Do I need to set the bitrate anywhere?
I was trying this library using the LAN8720 but I'm getting the message that the request failed.
I'm using I2Saudio.ino as an example.
The library works just fine over WIFI and the LAN8720 can also perform get requests without a problem.
Does anyone have any idea wat could go wrong?
Thank you Wolle for just a wonderful library, I enjoy so much this stable code. you're a hero..
Is this a coming option?
Hello.
Do you plan to enhance library to use additional 4 or 8 MB of PSRAM as an stream buffer on new ESP32 modules?
When the internet is stable everything is fine, but when the internet is unstable (e.g. while listening to the radio in a car or there are problems with network) there are a lot of buffer underruns. The same station on mobile phone or PC works perfectly.
thanks,
wk
m_validSamples is being used uninitialized, which can result in stopping playback of a file very rapidly.
I recommend setting Arduino preference "Compiler warnings" to "More" to catch this kind of mistakes.
Thanks for the project!
Found a small error when playing streams with encryption in particular https, some streams sent the controller to reboot. Others did not play correctly.
Audio.cpp
https://github.com/schreibfaul1/ESP32-audioI2S/blob/master/src/Audio.cpp
Actual for nttp flows
line 924 int b = client.read ();
completely forgot about https)
I propose to replace it with:
int b;
if (m_f_ssl == false)
{
b = client.read ();
}
if (m_f_ssl == true)
{
b = clientsecure.read ();
}
And also exclude the condition
line 823
if ( bytesAddedToBuffer == 0 )
{
if ( m_f_stream )
{
m_f_stream = false;
i2s_zero_dma_buffer((i2s_port_t)m_i2s_num);
if(audio_info) audio_info("stream lost");
}
}
Sorry for my English)
Hi,
Me again. Would it be possible to include more examples.
Playing a Mp3 or wave file from SPiffs and program mem would be awesome.
Well done again.
Super nice library.
Dans
Hey Wolle!
ich kann mit deiner Library nicht Google TTS benutzen. Es erscheint ein kurzes Klacken im Lautsprecher und danach tut sich nichts mehr. Das MP3s Abspielen hatte früher super geklappt, jedoch habe ich nun Probleme mit dem Mounten der SD Karte... Welches Format benutzt du? FAT32?
Wie auch immer, es wäre schön, wenn du mir bei dem TTS Problem helfen könntest!
LG Sinan Akkoyun
What means "MP3 decode error -2"?
I have an SD card filled with small .wav files and I am trying to find a way to play specific ones on command. The current examples queue up a single file to be played in the setup() then plays it when the board starts.
What I am looking to do is play a list of files from a function so say I press a button the triggers the function and plays a file, press a different button and a different file plays. I will also need to string a few files together to play one after the other.
Here is what I have so far:
#include "Audio.h"
#include "SD.h"
#include "FS.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
#define buttonPin 2
#define ledPin 0
int buttonState = 0;
Audio audio;
void setup() {
pinMode(SD_CS, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
SD.begin(SD_CS);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // 0...21
audio.connecttoFS(SD, "100.wav");
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
playsound();
} else {
digitalWrite(ledPin, LOW);
}
}
void playsound()
{
audio.loop();
}
This works, but only once before I need to reset the board.
void setup() {
pinMode(SD_CS, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
SD.begin(SD_CS);
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(10); // 0...21
// audio.connecttoFS(SD, "100.wav"); <---Removed
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
playsound();
} else {
digitalWrite(ledPin, LOW);
}
}
void playsound()
{
audio.connecttoFS(SD, "100.wav");
audio.loop();
}
This does not, nothing plays.
So the main question is how do I get that connecttoFS bit to work outside of the main setup function?
Eventually I want something akin to this:
void playsound (string file) {
audio.connecttoFS(SD, file);
audio.loop();
}
Then somewhere else:
playsound ("Hello.wav");
playsound ("World.wav");
if buttonPressed=1 {
playsound ("Foo.wav");
} elseif buttonPressed=2 {
playsound ("bar.wav");
}
Any ideas on how to get this to work with this library?
If the radio works and change the volume, then the radio stops working. Need to restart "audio.connecttohost". Is it possible to change the volume without stopping the radio?
Iheart radio streams use a "301 redirect". I tried replacing the HTTPS Client with the HTTPSRedirect (https://github.com/electronicsguy/ESP8266/tree/master/HTTPSRedirect - works by replacing "client") , and though the redirect now occurs, it still is not loading the stream. Could someone provide second set of eyes on what might be the problem?
Sample stream
https://stream.revma.ihrhls.com/zc4422
---> redirects to ->>
https://n2ba-e2.revma.ihrhls.com/zc4422?rj-ttl=5&rj-tok=AAABc8lJKsoApd8aBgVQsiq9IQ
I found a Bluetooth Speaker project with ESP32:
[#10] DIY DSP Bluetooth Speaker with ESP32
Would it be possible to add this functionality to the project?
Hi,
I am running multiple ESPs with 5102s as a multiroom audio. I start them all by
audio.connecttohost(station);
send to the same mqtt topic, which makes them start almost simultaneous.
Audio sending device is a Raspberry 3 using Darkice (1 sec buffer, prio 4) which runs fine for the first 20 minutes up to an hour.
But sooner or later it starts to become asynchron, no matter if I stream Spotify, from the phone, or play a local file.
The ESPs do not host anything besides WLAN, MQTT, OTA and the music stuff. Also, the loop() - task has the highest priority among my tasks.
For now I changed getAudioCurrentTime() to return the time as float, and as soon as the difference is bigger then 0.07 I call stopSong(), followed by a small delay and connecttohost() on all devices, so they play sinchronous again after ~ 1+ second.
This solution has two problems:
However, I do not even half understand your code good enough to maybe find a better solution.
For me one way could be to have an option to just play silence if data is not received, f.e. fill music array blank. This way the devices would always play synchronous, no upcoming and hearable out-of-syncing, only very short missing of sound. Especially for podcasts a very nice solution.
Another way (maybe the best) could be, as I read the request about more buffer: more buffer also on 4mb devices. If they could buffer a few hundred milliseconds, the problem would occur "far" later. Mayber with an option to check the remaining buffer size, so shortly before an out of sync I could resync if necessary.
Or, if both is not an option, a callback which informs about every gap the moment it occurs, maybe followed by the information of it´s length, so a resync could occur very short after, without checking the playtime of all devices.
A few years ago, I made a program (in Python) that saved the voice mp3 file for offline use, because sometimes it may be unavailable to the internet, or it needs to operate offline full time.
This site helps you to store the audio file for offline use:
https://ttsmp3.com/
Hello, we are considering to add this code into our project.
Would you mind specifying the license? Is it permissive, copyleft or proprietary?
Could you please help, i am unable to compile, here is my error
Archiving built core (caching) in: /tmp/arduino_cache_561838/core/core_esp32_esp32_esp32_PSRAM_disabled,PartitionScheme_default,CPUFreq_240,FlashMode_qio,FlashFreq_80,FlashSize_4M,UploadSpeed_921600,DebugLevel_none_c553e1c789170525c91403689da85e69.a
Multiple libraries were found for "SD.h"
Used: /home/ossama/snap/arduino-mhall119/5/.arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/SD
Not used: /snap/arduino-mhall119/5/libraries/SD
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xbc): undefined reference to MP3FindSyncWord(unsigned char*, int)' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xc0): undefined reference to
AACFindSyncWord(unsigned char*, int)'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xc4): undefined reference to MP3Decode(unsigned char*, int*, short*, int)' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xc8): undefined reference to
AACDecode(unsigned char*, int*, short*)'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xcc): undefined reference to MP3GetChannels()' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xd0): undefined reference to
MP3GetSampRate()'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xd8): undefined reference to MP3GetBitsPerSample()' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xdc): undefined reference to
MP3GetBitrate()'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xe0): undefined reference to MP3GetOutputSamps()' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xe4): undefined reference to
AACGetChannels()'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xe8): undefined reference to AACGetSampRate()' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xec): undefined reference to
AACGetBitsPerSample()'
sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xf0): undefined reference to AACGetBitrate()' sketch/Audio.cpp.o:(.literal._ZN5Audio9sendBytesEPhj+0xf4): undefined reference to
AACGetOutputSamps()'
sketch/Audio.cpp.o: In function Audio::sendBytes(unsigned char*, unsigned int)': sketch/Audio.cpp:1706: undefined reference to
MP3FindSyncWord(unsigned char*, int)'
sketch/Audio.cpp:1706: undefined reference to AACFindSyncWord(unsigned char*, int)' sketch/Audio.cpp:1706: undefined reference to
MP3Decode(unsigned char*, int*, short*, int)'
sketch/Audio.cpp:1706: undefined reference to AACDecode(unsigned char*, int*, short*)' sketch/Audio.cpp:1706: undefined reference to
MP3GetChannels()'
sketch/Audio.cpp:1706: undefined reference to MP3GetChannels()' sketch/Audio.cpp:1706: undefined reference to
MP3GetChannels()'
sketch/Audio.cpp:1706: undefined reference to MP3GetChannels()' sketch/Audio.cpp:1706: undefined reference to
MP3GetSampRate()'
sketch/Audio.cpp:1706: undefined reference to MP3GetSampRate()' sketch/Audio.cpp:1706: undefined reference to
MP3GetSampRate()'
sketch/Audio.cpp:1706: undefined reference to MP3GetSampRate()' sketch/Audio.cpp:1706: undefined reference to
MP3GetSampRate()'
sketch/Audio.cpp.o:sketch/Audio.cpp:1706: more undefined references to MP3GetSampRate()' follow sketch/Audio.cpp.o: In function
Audio::sendBytes(unsigned char*, unsigned int)':
sketch/Audio.cpp:1706: undefined reference to MP3GetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
MP3GetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to MP3GetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
MP3GetBitrate()'
sketch/Audio.cpp:1706: undefined reference to MP3GetBitrate()' sketch/Audio.cpp:1706: undefined reference to
MP3GetBitrate()'
sketch/Audio.cpp:1706: undefined reference to MP3GetOutputSamps()' sketch/Audio.cpp:1706: undefined reference to
AACGetChannels()'
sketch/Audio.cpp:1706: undefined reference to AACGetChannels()' sketch/Audio.cpp:1706: undefined reference to
AACGetChannels()'
sketch/Audio.cpp:1706: undefined reference to AACGetChannels()' sketch/Audio.cpp:1706: undefined reference to
AACGetSampRate()'
sketch/Audio.cpp:1706: undefined reference to AACGetSampRate()' sketch/Audio.cpp:1706: undefined reference to
AACGetSampRate()'
sketch/Audio.cpp:1706: undefined reference to AACGetSampRate()' sketch/Audio.cpp:1706: undefined reference to
AACGetSampRate()'
sketch/Audio.cpp.o:sketch/Audio.cpp:1706: more undefined references to AACGetSampRate()' follow sketch/Audio.cpp.o: In function
Audio::sendBytes(unsigned char*, unsigned int)':
sketch/Audio.cpp:1706: undefined reference to AACGetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitrate()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitrate()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitrate()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitrate()' sketch/Audio.cpp:1706: undefined reference to
AACGetOutputSamps()'
sketch/Audio.cpp:1706: undefined reference to MP3GetSampRate()' sketch/Audio.cpp:1706: undefined reference to
AACGetSampRate()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitrate()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitrate()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitrate()' sketch/Audio.cpp:1706: undefined reference to
MP3GetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to MP3GetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
MP3GetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitsPerSample()' sketch/Audio.cpp:1706: undefined reference to
AACGetBitsPerSample()'
sketch/Audio.cpp:1706: undefined reference to AACGetBitsPerSample()' sketch/Audio.cpp.o:sketch/Audio.cpp:1706: more undefined references to
AACGetBitsPerSample()' follow
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board ESP32 Dev Module.
uint8_t Audio::getVolume(){
return m_vol;
}
to
uint8_t Audio::getVolume(){
for(int i = 0; i < 22; i++){
if(volumetable[i] == m_vol) return i;
}
}
Is it possible to adjust the playback speed of a specific MP3, so it plays a little faster or slower than the file was intended for? I'd like to be able to crudely change pitch.
I am creating a web interface for this wonderful library. But I ran into a reboot problem.
String station;
audio.connecttohost (station);
As soon as the variable takes on a text value with the station address, the Internet radio starts to sound. Is this normal or a bug in the library?
Is it possible to find out if the audio stream is currently in progress?
Sorry for my English. I use google translator.
Hi,
It's not really an issue of this project. Is it possible to write the audio position to the sd card? If i try to get the audio position by calling audio.getFilePos(); the esp32 crashes.
what am I doing wrong?
abort() was called at PC 0x400854c9 on core 1
Backtrace: 0x4008c8c8:0x3ffbe660.......................
Hi, I have made a change to use 'SD_MMC' instead of 'SD' and I've just tested it with the MAX98357A. I'm getting a fair bit of noise on the speaker (Visaton FR7) which is probably because my whole setup is with jumper wires at this stage.
I changed SD
to SD_MMC
in Audio.h and Audio.cpp
The issue I'm having is the speaker going quiet and accompanied by this error message (and startup info for context)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
E (31658) sdmmc_cmd: sdmmc_read_sectors_dma: sdmmc_send_cmd returned 0x109
E (31658) diskio_sdmmc: sdmmc_read_blocks failed (265)
If you have any hints from a software perspective, I'd be grateful. I don't know whether to spin a custom PCB to try and improve signal integrity or to get it solved with the breadboard/jumper wire version first, so I know if it's workable. The mp3 file I'm using is at 271kbps but I'd be surprised if SD_MMC was struggling to transfer the data where you already have shown it working with existing files at the slower SD rates.
I know your library doesn't support SD_MMC
at the moment but if I can get it working, it might be helpful for some people who want to increase the speed at which they can upload their files wirelessly (which is what I'm hoping to use it for, as an improvement over SD
).
Thanks
Code for reference is:
* Xtronical code from https://www.xtronical.com/esp32mp3/
*/
#include "Arduino.h"
#include "Audio.h"
#include "SD_MMC.h" // amended from SD
#include <SPI.h> // added
#include "FS.h"
// Digital I/O used
//#define SD_CS 5
//#define SPI_MOSI 23 // SD Card
//#define SPI_MISO 19
//#define SPI_SCK 18
#define I2S_DOUT 25
#define I2S_BCLK 27 // I2S
#define I2S_LRC 26
Audio audio;
void setup() {
//pinMode(SD_CS, OUTPUT);
//digitalWrite(SD_CS, HIGH);
//SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
if(!SD_MMC.begin())
{
Serial.println("Error talking to SD card!");
while(true); // end program
}
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(1); // 0...21
audio.connecttoFS(SD_MMC,"/music01.mp3");
}
void loop()
{
audio.loop();
}
Thanks a lot for the code. You can enable MCLK generation to make this application compatible with any I2S DAC. I had a problem with my home-brew TAS5753MD I2S power amp - it can only generate an MCLK internally for specific combinations of BCK and WS. With this fix , it works great !
Of course you can just put the two lines of code in the Audio library I2S init code.
(credit https://www.youtube.com/watch?v=WsDwj6SENOE, this guy is amazing and needs more appreciation)
Hey Schreibfaul,
könntest du mir bitte helfen deine Library auf die ESP-IDF zu porten?
InitDecoders KEYWORD2
connecttoSD KEYWORD2
to
InitDecoders<TAB>KEYWORD2
connecttoSD<TAB>KEYWORD2
Hi,
it looks like sketch is too big.. "Sketch uses 2263350 bytes (172%) of program storage space"
You can compile it?
If I wanted to add JSON web Tokens or some type of authorization to access an MP3 file on top of HTTPS is there an easy way to do that?
Thanks
During playback of online radio, there are some interruptions due to the use of the internet band.
Would it be possible to add a buffer of about 5 seconds to avoid this problem?
Thanks for the useful library.
Do you intend to add ogg decoder soon?
Hi
Kudos for the great work here. I don't understand everything when it comes to mp3 decoding, but i am running into a dead end with a file at this address :
http://media.radiofrance-podcast.net/podcast09/10059-31.03.2019-ITEMA_22023210-0.mp3
It seems the decoder has trouble reading it, and that end up messing the bitrate detection, giving the ERR_FREE_BITRATE_SYNC.
It's looking for a proper frame, skipping many of them, then calculates a zero bitrate, starts looking again, find a frame, and then crashes :
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception) Debug exception reason: /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/tasks.c:2331 (pcTaskGetTaskName)- assert failed! abort() was called at PC 0x4008ff96 on core 0
Any idea what cause such error in this particular file (and of every files of this radio) ? Could I default the bitrate to 128 if it cannot be calculated ?
Cheers !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.