earlephilhower / ESP8266Audio

Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32
GNU General Public License v3.0
2.01k stars 432 forks source link

Play a lot of broken wav music #503

Open gianglongtbe opened 2 years ago

gianglongtbe commented 2 years ago

The program is restarting after a while, please help. thank you!

include

ifdef ESP32

include

include "SPIFFS.h"

else

include

endif

include "AudioFileSourceSPIFFS.h"

include "AudioOutputI2SNoDAC.h"

//#include "AudioFileSourcePROGMEM.h"

include "AudioGeneratorWAV.h"

//#include "AudioOutputI2SNoDAC.h"

include "AudioFileSourceBuffer.h"

// To run, set your ESP8266 build to 160MHz, and include a SPIFFS of 512KB or greater. // Use the "Tools->ESP8266/ESP32 Sketch Data Upload" menu to write the MP3 to SPIFFS // Then upload the sketch normally.

// pno_cs from https://ccrma.stanford.edu/~jos/pasp/Sound_Examples.html

AudioGeneratorWAV wav; AudioFileSourceSPIFFS file; AudioOutputI2SNoDAC out; AudioFileSourceBuffer buff;

void setup() { Serial.begin(115200); delay(1000); Serial.printf("WAV start\n");

audioLogger = &Serial; file = new AudioFileSourceSPIFFS("/music.wav"); buff = new AudioFileSourceBuffer (file, 4056 ); out = new AudioOutputI2SNoDAC(); wav = new AudioGeneratorWAV(); wav->begin(buff, out); //wav->begin(file, out); }

void loop() { wav->isRunning(); for (int i = 0; i < 65000; i++) { wav->loop(); } wav->stop(); // delete wav; // delete file; Serial.printf("WAV done\n"); delay(100);

file = new AudioFileSourceSPIFFS("/music1.wav"); buff = new AudioFileSourceBuffer (file, 4056 ); out = new AudioOutputI2SNoDAC(); wav = new AudioGeneratorWAV(); wav->begin(buff, out); wav->isRunning(); for (int i = 0; i < 65000; i++) { wav->loop(); } wav->stop(); // delete wav; // delete file; Serial.printf("WAV done\n"); delay(100);

file = new AudioFileSourceSPIFFS("/music2.wav"); buff = new AudioFileSourceBuffer (file, 4056 ); out = new AudioOutputI2SNoDAC(); wav = new AudioGeneratorWAV(); wav->begin(buff, out); wav->isRunning(); for (int i = 0; i < 65000; i++) { wav->loop(); } wav->stop(); // delete wav; // delete file; Serial.printf("WAV done\n"); delay(100);

file = new AudioFileSourceSPIFFS("/music3.wav"); buff = new AudioFileSourceBuffer (file, 4056 ); out = new AudioOutputI2SNoDAC(); wav = new AudioGeneratorWAV(); wav->begin(buff, out); wav->isRunning(); for (int i = 0; i < 65000; i++) { wav->loop(); } wav->stop(); // delete wav; // delete file; Serial.printf("WAV done\n"); delay(100);

file = new AudioFileSourceSPIFFS("/music4.wav"); buff = new AudioFileSourceBuffer (file, 4056 ); out = new AudioOutputI2SNoDAC(); wav = new AudioGeneratorWAV(); wav->begin(buff, out); }

WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] WAV done Unable to allocate AudioFileSourceBuffer::buffer[] AudioGeneratorWAV::begin: failed during ReadWAVInfo WAV done

User exception (panic/abort/assert) --------------- CUT HERE FOR EXCEPTION DECODER ---------------

Unhandled C++ exception: OOM

stack>>>

ctx: cont sp: 3ffef830 end: 3ffef8f0 offset: 0000 3ffef830: 0a6f666e 3fffbd00 3fff00e0 00000001
3ffef840: 000000fe 00000000 00000000 00000000
3ffef850: 00000000 00000000 00000000 00000001
3ffef860: 00007fff 00000000 3ffef9a8 3ffee690
3ffef870: 3ffee76c 402012e2 00000048 40209c02
3ffef880: 3ffee76c 402012e2 00000020 40209c21
3ffef890: 40209d35 00000064 00000048 40208b0c
3ffef8a0: 3ffee76c 3ffe8846 3ffee69c 402012e2
3ffef8b0: 3fffbd54 00000000 00000001 4010037c
3ffef8c0: 3fffdad0 00000000 3ffef92c 3ffef940
3ffef8d0: 3fffdad0 00000000 3ffef92c 40209768
3ffef8e0: feefeffe feefeffe 3ffe8648 40100e99
<<<stack<<<

last failed alloc call: 402012E2(72)

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

last failed alloc caller: 0x402012e2

ets Jan 8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 tail 4 chksum 0xcc load 0x3fff20b8, len 40, room 4 tail 4 chksum 0xc9 csum 0xc9 v00055830 ~ld WAV start WAV done WAV done WAV done