3 #include "AudioBasic/StrExt.h"
4 #include "AudioLogger.h"
5 #include "AudioTools/AudioSource.h"
6 #include "AudioLibs/SDDirect.h"
37 AudioSourceSD(
const char *startFilePath =
"/",
const char *ext =
".mp3",
int chipSelect = PIN_CS,
bool setupIndex=
true) {
38 start_path = startFilePath;
40 setup_index = setupIndex;
47 while (!SD.begin(cs)) {
48 LOGE(
"SD.begin cs=%d failed",cs);
53 idx.begin(start_path, exension, file_name_pattern);
63 LOGI(
"nextStream: %d", offset);
68 LOGI(
"selectStream: %d",
index);
70 file_name = idx[
index];
71 if (file_name==
nullptr)
return nullptr;
72 LOGI(
"Using file %s", file_name);
73 file = SD.open(file_name);
74 return file ? &file :
nullptr;
80 file_name = file.name();
81 LOGI(
"-> selectStream: %s", path);
82 return file ? &file :
nullptr;
93 const char *
toStr() {
return file_name; }
99 virtual void setPath(
const char *p) { start_path = p; }
105 #if defined(USE_SD_NO_NS)
108 SDDirect<fs::SDFS,fs::File> idx{SD};
112 const char *file_name;
113 const char *exension =
nullptr;
114 const char *start_path =
nullptr;
115 const char *file_name_pattern =
"*";
116 bool setup_index =
true;
117 bool is_sd_setup =
false;