Comments (7)
It looks like this issue has been raised in issue #45 but it was closed as a "cannot reproduce". Trying the sample file with an ESP32 S3 with no psram will make it 100% reproducible.
The approach in the @eziya fork is to essentially not use interrupts
from adafruit_vs1053_library.
The issue is with interrupt playback. That currently is not working for ESP32 platforms. In the player_simple.ino
example, comment out this line:
musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT); // DREQ int
and then it should work for the non-interrupt playback call to:
musicPlayer.playFullFile("/track001.mp3");
The subsequent interrupt based playback call(s) will not work however:
musicPlayer.startPlayingFile("/track002.mp3");
Do not have the breakout version of this to test. However, using a Feather ESP32-S3 (PID 5323) and commenting out the DREQ setup in feather_player.ino
works.
from adafruit_vs1053_library.
I can confirm that removing the interrupt does work. As suggested, playFullFile does play the full file. Using startPlayingFile also works if you make sure to fill the buffer in your loop:
void loop() {
musicPlayer.feedBuffer();
// more stuff here
}
This works as long as the loop time is less than 150ms so the buffer stays full. It would be quite easy to add a timer that can just keep the buffer filled. I might make use this approach. I can do a PR on this if it's useful?
from adafruit_vs1053_library.
I dont think a timer will work, because thise time depends in the bitrate of the file and probably even more factors. DREQ pin is specifically there to tell you when it is time to send more data, so „watching“ it, with or without interrupt, is the best approach here.
from adafruit_vs1053_library.
Spent some more time on this. What is crashing is reading from SD inside an interrupt. If I just set a flag in the interrupt and then check this flag in the loop, it works fine. Here's an example that is using interrupts, but just not to fill the buffer: https://pastebin.com/qwcJVs8E
It is basically the same as calling the feedBuffer routine from the main loop, but it will only do it when required. I would like to get this to work with interrupts, but I'm unsure where to go next. Any hints helpful!
sidenote: I've tried using the SDFat option present in the library, but it looks like that's not been maintained in a while? Setting PREFER_SDFAT_LIBRARY yields compilation errors. Tried using adafruit/SdFat - Adafruit Fork@^1.5.1 as well as 2.2.1. Slightly different output
from adafruit_vs1053_library.
Turns out that it's not hard to get this working by using FreeRtos Functions. Adding the following code to Adafruit_VS1053.cpp will use a FreeRTOS Task to poll the feedBuffer routine.
I can deliver a PR if you think this is a good way to solve it. I can also test it. My current fork of the library allows me to play files directly from SPIFFS or any other files system.
static void feedEsp32( void * pvParameters ){
for(;;){
myself->feedBuffer();
delay(10);
}
}
boolean Adafruit_VS1053_FilePlayer::useInterrupt(uint8_t type) {
myself = this; // oy vey
if (type == VS1053_FILEPLAYER_TIMER0_INT) {
#if defined(ARDUINO_ARCH_AVR)
OCR0A = 0xAF;
TIMSK0 |= _BV(OCIE0A);
return true;
#elif defined(ESP32)
TaskHandle_t Task1;
xTaskCreatePinnedToCore(
feedEsp32, /* Task function. */
"Task1", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task1, /* Task handle to keep track of created task */
0); /* pin task to core 0 */
#elif defined(__arm__) && defined(CORE_TEENSY)
Here's my current code master...jenschr:Adafruit_VS1053_Library:master
I don't think it's possible to get the non-timer method to ever work on ESP32 (ref: Calling long ISR's will crash ), so in my codebase, I'm printing out a warning on Serial if this is used.
from adafruit_vs1053_library.
Related Issues (20)
- Cant compile record_ogg HOT 2
- Distorted *.wav files HOT 1
- Millis() function is extremely inaccurate when playing audio on Feather M0 HOT 2
- "Adafruit_VS1053.cpp" problem with "feather_player" exemple HOT 2
- record_ogg example does not support multiple recordings without reset HOT 2
- setVolume ranges? HOT 1
- Travis Build Broken HOT 1
- Error in compilation for Arduino Uno WiFi Rev2 HOT 2
- Compiler error when using a Arduino Nano Every (ATMega4809) HOT 4
- Problem with begin() HOT 1
- how to use the applyPatch() function? HOT 4
- Not really a issue but.. HOT 7
- custom SPI pins not working on ESP32 HOT 29
- Convert to BusIO HOT 1
- Strange error occurs once and again while using Music Maker
- Increase SPI clock? HOT 1
- Please fix sdfat HOT 4
- Using SDfat on RP2040 (earlephilhower core) HOT 1
- Issue with Ogg Recording Example on VS1053 Breakout Board
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adafruit_vs1053_library.