Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ extra_scripts =
pre:updateSdkConfig.py
pre:processHtml.py
lib_deps =
https://github.com/schreibfaul1/ESP32-audioI2S.git#160b164 ; v3.4.0
https://github.com/schreibfaul1/ESP32-audioI2S.git#6b8264c ; v3.4.2+ set time offset
https://github.com/madhephaestus/ESP32Encoder.git#2c986e0
https://github.com/peterus/ESP-FTP-Server-Lib.git#554959f
https://github.com/FastLED/FastLED.git#f5c78fd ; v3.10.1+ fix of issue 16188
https://github.com/FastLED/FastLED.git#3d1f9fe ; v3.10.2
https://github.com/ESP32Async/ESPAsyncWebServer.git#35ee69e ; v3.7.10
https://github.com/bblanchon/ArduinoJson.git#3252013 ; v7.4.1
https://github.com/pschatzmann/arduino-audio-tools.git#c19fbd6 ; v1.0.2
Expand All @@ -56,7 +56,7 @@ board_build.embed_txtfiles =
build_flags =
-DCONFIG_ASYNC_TCP_RUNNING_CORE=0
-DCONFIG_ASYNC_TCP_USE_WDT=1
; -DCORE_DEBUG_LEVEL=6
-DCORE_DEBUG_LEVEL=0 ;6
-std=c++17
-std=gnu++17
-Wall
Expand Down
32 changes: 16 additions & 16 deletions src/AudioPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,13 +428,11 @@ void AudioPlayer_Loop() {
AudioPlayer_CurrentTime = audio->getAudioCurrentTime();
AudioPlayer_FileDuration = audio->getAudioFileDuration();
// Calculate relative position in file (for trackprogress neopixel & web-ui)
uint32_t fileSize = audio->getFileSize();
gPlayProperties.audioFileSize = fileSize;
if (!gPlayProperties.playlistFinished && fileSize > 0) {
gPlayProperties.audioFileDuration = AudioPlayer_FileDuration;
if (!gPlayProperties.playlistFinished && AudioPlayer_FileDuration > 0) {
// for local files and web files with known size
if (!gPlayProperties.pausePlay && (gPlayProperties.seekmode != SEEK_POS_PERCENT)) { // To progress necessary when paused
uint32_t audioDataStartPos = audio->getAudioDataStartPos();
gPlayProperties.currentRelPos = ((double) (audio->getFilePos() - audioDataStartPos - audio->inBufferFilled()) / (fileSize - audioDataStartPos)) * 100;
gPlayProperties.currentRelPos = ((float) audio->getAudioCurrentTime() / audio->getAudioFileDuration()) * 100.0f;
}
} else {
if (gPlayProperties.isWebstream && (audio->getInBufferSize() > 0)) {
Expand Down Expand Up @@ -528,8 +526,8 @@ void AudioPlayer_Loop() {
Log_Println(cmndPause, LOGLEVEL_INFO);
}
if (gPlayProperties.saveLastPlayPosition && !gPlayProperties.pausePlay) {
Log_Printf(LOGLEVEL_INFO, trackPausedAtPos, audio->getFilePos(), audio->getFilePos() - audio->inBufferFilled());
AudioPlayer_NvsRfidWriteWrapper(gPlayProperties.playRfidTag, gPlayProperties.playlist->at(gPlayProperties.currentTrackNumber), audio->getFilePos() - audio->inBufferFilled(), gPlayProperties.playMode, gPlayProperties.currentTrackNumber, gPlayProperties.playlist->size());
Log_Printf(LOGLEVEL_INFO, trackPausedAtPos, audio->getAudioCurrentTime(), audio->getAudioFileDuration());
AudioPlayer_NvsRfidWriteWrapper(gPlayProperties.playRfidTag, gPlayProperties.playlist->at(gPlayProperties.currentTrackNumber), audio->getAudioCurrentTime(), gPlayProperties.playMode, gPlayProperties.currentTrackNumber, gPlayProperties.playlist->size());
}
gPlayProperties.pausePlay = !gPlayProperties.pausePlay;
Web_SendWebsocketData(0, WebsocketCodeType::TrackInfo);
Expand Down Expand Up @@ -744,7 +742,14 @@ void AudioPlayer_Loop() {
gPlayProperties.trackFinished = true;
return;
} else {
audioReturnCode = audio->connecttoFS(gFSystem, gPlayProperties.playlist->at(gPlayProperties.currentTrackNumber));
int32_t fileStartTime = -1;
if (gPlayProperties.startAtFilePos > 0) {
fileStartTime = gPlayProperties.startAtFilePos;
Log_Printf(LOGLEVEL_NOTICE, trackStartatPos, gPlayProperties.startAtFilePos);
gPlayProperties.startAtFilePos = 0;
}
audioReturnCode
= audio->connecttoFS(gFSystem, gPlayProperties.playlist->at(gPlayProperties.currentTrackNumber), fileStartTime);
// consider track as finished, when audio lib call was not successful
}
}
Expand All @@ -757,11 +762,6 @@ void AudioPlayer_Loop() {
if (gPlayProperties.currentTrackNumber) {
Led_Indicate(LedIndicatorType::PlaylistProgress);
}
if (gPlayProperties.startAtFilePos > 0) {
audio->setFilePos(gPlayProperties.startAtFilePos);
Log_Printf(LOGLEVEL_NOTICE, trackStartatPos, gPlayProperties.startAtFilePos);
gPlayProperties.startAtFilePos = 0;
}
const char *title = gPlayProperties.playlist->at(gPlayProperties.currentTrackNumber);
if (gPlayProperties.isWebstream) {
title = "Webradio";
Expand Down Expand Up @@ -792,9 +792,9 @@ void AudioPlayer_Loop() {
System_IndicateError();
}
} else if ((gPlayProperties.seekmode == SEEK_POS_PERCENT) && (gPlayProperties.currentRelPos > 0) && (gPlayProperties.currentRelPos < 100)) {
uint32_t newFilePos = uint32_t((double) audio->getAudioDataStartPos() * (1 - gPlayProperties.currentRelPos / 100) + (gPlayProperties.currentRelPos / 100) * audio->getFileSize());
if (audio->setFilePos(newFilePos)) {
Log_Printf(LOGLEVEL_NOTICE, JumpToPosition, newFilePos, audio->getFileSize());
uint32_t newFileTime = uint32_t((gPlayProperties.currentRelPos / 100.0f) * audio->getAudioFileDuration());
if (audio->setAudioPlayTime(newFileTime)) {
Log_Printf(LOGLEVEL_NOTICE, JumpToPosition, newFileTime, audio->getAudioFileDuration());
} else {
System_IndicateError();
}
Expand Down
4 changes: 2 additions & 2 deletions src/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct { // Bit field
bool repeatCurrentTrack : 1; // If current track should be looped
bool repeatPlaylist : 1; // If whole playlist should be looped
uint16_t currentTrackNumber : 9; // Current tracknumber
unsigned long startAtFilePos; // Offset to start play (in bytes)
unsigned long startAtFilePos; // Offset to start play (in seconds)
double currentRelPos; // Current relative playPosition (in %)
bool sleepAfterCurrentTrack : 1; // If uC should go to sleep after current track
bool sleepAfterPlaylist : 1; // If uC should go to sleep after whole playlist
Expand All @@ -48,7 +48,7 @@ typedef struct { // Bit field
int8_t gainHighPass = 0; // High Pass for EQ Control
size_t coverFilePos; // current cover file position
size_t coverFileSize; // current cover file size
size_t audioFileSize; // file size of current audio file
size_t audioFileDuration; // file duration of current audio file (in seconds)
} playProps;

extern playProps gPlayProperties;
Expand Down
2 changes: 1 addition & 1 deletion src/Led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ static void Led_Task(void *parameter) {
nextAnimation = LedAnimationType::Idle;
} else if (gPlayProperties.pausePlay && !gPlayProperties.isWebstream) {
nextAnimation = LedAnimationType::Pause;
} else if ((gPlayProperties.playMode != BUSY) && (gPlayProperties.playMode != NO_PLAYLIST) && gPlayProperties.audioFileSize > 0) { // progress for a file/stream with known size
} else if ((gPlayProperties.playMode != BUSY) && (gPlayProperties.playMode != NO_PLAYLIST) && gPlayProperties.audioFileDuration > 0) { // progress for a file/stream with known size
nextAnimation = LedAnimationType::Progress;
} else if (gPlayProperties.isWebstream) { // webstream animation (for streams with unknown size); pause animation is also handled by the webstream animation function
nextAnimation = LedAnimationType::Webstream;
Expand Down
Loading