4#include "AudioLogger.h"
5#include "AudioTools/Disk/AudioSource.h"
35 AudioSourceSD(
const char *startFilePath =
"/",
const char *ext =
".mp3",
int chipSelect = PIN_CS,
bool setupIndex=
true) {
36 start_path = startFilePath;
38 setup_index = setupIndex;
43#ifdef USE_SD_SUPPORTS_SPI
46 AudioSourceSD(
const char *startFilePath,
const char *ext,
int chipSelect, SPIClass &spiInstance,
bool setupIndex=
true) {
47 start_path = startFilePath;
49 setup_index = setupIndex;
61 LOGE(
"SD.begin cs=%d failed", cs);
69 idx.begin(start_path, extension, file_name_pattern);
80 LOGI(
"nextStream: %d", offset);
85 LOGI(
"selectStream: %d",
index);
87 file_name = idx[
index];
88 if (file_name==
nullptr)
return nullptr;
89 LOGI(
"Using file %s", file_name);
90 file = SD.open(file_name);
91 return file ? &file :
nullptr;
97 file_name = file.name();
98 LOGI(
"-> selectStream: %s", path);
99 return file ? &file :
nullptr;
110 const char *
toStr() {
return file_name; }
116 virtual void setPath(
const char *p) { start_path = p; }
122#if defined(USE_SD_NO_NS)
125 SDDirect<fs::SDFS,fs::File> idx{SD};
129 const char *file_name;
130 const char *extension =
nullptr;
131 const char *start_path =
nullptr;
132 const char *file_name_pattern =
"*";
133 bool setup_index =
true;
134 bool is_sd_setup =
false;
136 SPIClass *p_spi =
nullptr;
139#ifdef USE_SD_SUPPORTS_SPI
140 return SD.begin(cs, *p_spi);