3 #include "AudioLogger.h"
4 #include "AudioTools/CoreAudio/AudioSource.h"
7 #include "AudioTools/AudioLibs/SDDirect.h"
35 AudioSourceSDMMC(
const char *startFilePath =
"/",
const char *ext =
".mp3",
bool setupIndex=
true) {
36 start_path = startFilePath;
38 setup_index = setupIndex;
44 if (!SD_MMC.begin(
"/sdcard",
true)) {
45 LOGE(
"SD_MMC.begin failed");
50 idx.begin(start_path, exension, file_name_pattern);
61 LOGI(
"nextStream: %d", offset);
66 LOGI(
"selectStream: %d",
index);
68 file_name = idx[
index];
69 if (file_name==
nullptr)
return nullptr;
70 LOGI(
"Using file %s", file_name);
71 file = SD_MMC.open(file_name);
72 return file ? &file :
nullptr;
77 file = SD_MMC.open(path);
78 file_name = file.name();
79 LOGI(
"-> selectStream: %s", path);
80 return file ? &file :
nullptr;
91 const char *
toStr() {
return file_name; }
97 virtual void setPath(
const char *p) { start_path = p; }
106 const char *file_name;
107 const char *exension =
nullptr;
108 const char *start_path =
nullptr;
109 const char *file_name_pattern =
"*";
110 bool setup_index =
true;
111 bool is_sd_setup =
false;