arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioSourceSDFAT Class Reference

ESP32 AudioSource for AudioPlayer using an SD card as data source. This class is based on the Arduino SD implementation Connect the SD card. For UTF8 Support change SdFatConfig.h define USE_UTF8_LONG_NAMES 1. More...

#include <AudioSourceSDFAT.h>

Inheritance diagram for AudioSourceSDFAT:
AudioSource AudioSource

Public Member Functions

 AudioSourceSDFAT (AudioFs fs, const char *startFilePath="/", const char *ext="", bool setupIndex=true)
 Constructor for providing an open FS.
 
 AudioSourceSDFAT (const char *startFilePath, const char *ext, SdSpiConfig &config)
 Costructor with SdSpiConfig.
 
 AudioSourceSDFAT (const char *startFilePath, const char *ext, SdSpiConfig &config, bool setupIndex=true)
 Costructor with SdSpiConfig.
 
 AudioSourceSDFAT (const char *startFilePath="/", const char *ext=".mp3", int chipSelect=PIN_CS, int speedMHz=10)
 Default constructor.
 
 AudioSourceSDFAT (const char *startFilePath="/", const char *ext=".mp3", int chipSelect=PIN_CS, int speedMHz=10, int spi_mode=DEDICATED_SPI, bool setupIndex=true)
 Default constructor.
 
virtual ~AudioSourceSDFAT ()
 Destructor.
 
virtual void begin () override
 Reset actual stream and move to root.
 
virtual void begin () override
 Reset actual stream and move to root.
 
void end ()
 
AudioFs & getAudioFs ()
 provides access to the AudioFs object
 
int index ()
 Provides the current index position.
 
int index ()
 Provides the current index position.
 
virtual bool isAutoNext ()
 Returns default setting go to the next.
 
virtual bool isAutoNext ()
 Returns default setting go to the next.
 
virtual StreamnextStream (int offset) override
 Returns next audio stream.
 
virtual StreamnextStream (int offset=1) override
 Returns next audio stream.
 
Streamoperator[] (int idx)
 access with array syntax
 
virtual StreampreviousStream (int offset)
 Returns previous audio stream.
 
virtual StreamselectStream (const char *path) override
 Returns audio stream by path.
 
virtual StreamselectStream (const char *path) override
 Returns audio stream by path.
 
virtual StreamselectStream (int index) override
 
virtual StreamselectStream (int index) override
 
void setFileFilter (const char *filter)
 
void setFileFilter (const char *filter)
 Defines the regex filter criteria for selecting files. E.g. ".*Bob Dylan.*".
 
virtual StreamsetIndex (int index)
 same as selectStream - I just prefer this name
 
virtual bool setMetadataCallback (void(*fn)(MetaDataType info, const char *str, int len), ID3TypeSelection sel=SELECT_ICY)
 
virtual void setPath (const char *p)
 Allows to "correct" the start path if not defined in the constructor.
 
virtual void setPath (const char *p)
 Allows to "correct" the start path if not defined in the constructor.
 
virtual void setTimeout (int ms)
 Sets the timeout of Stream in milliseconds.
 
virtual void setTimeoutAutoNext (int millisec)
 
long size ()
 
virtual int timeoutAutoNext ()
 Provides the timeout which is triggering to move to the next stream.
 
const char * toStr ()
 provides the actual file name
 
const char * toStr ()
 provides the actual file name
 

Protected Member Functions

void getFileAtIndex (AudioFile dir, size_t pos, size_t &idx, AudioFile &result)
 
AudioFile getFileByPath (const char *path)
 
AudioFile getFileByPos (const char *dirStr, int pos)
 Determines the file at the indicated index (starting with 0)
 
const char * getFileName (AudioFile &file)
 
bool isValidAudioFile (AudioFile &file)
 checks if the file is a valid audio file
 

Protected Attributes

int cs
 
const char * exension = nullptr
 
AudioFile file
 
char file_name [MAX_FILE_LEN]
 
const char * file_name_pattern = "*"
 
char * file_name_pattern = (char*) "*"
 
SDDirect< AudioFs, AudioFile > idx {sd}
 
size_t idx_pos = 0
 
bool is_close_sd = true
 
bool is_sd_setup = false
 
bool owns_cfg = false
 
SdSpiConfig * p_cfg = nullptr
 
AudioFs sd
 
bool setup_index = true
 
const char * start_path = nullptr
 
int timeout
 
int timeout_auto_next_value = 500
 

Detailed Description

ESP32 AudioSource for AudioPlayer using an SD card as data source. This class is based on the Arduino SD implementation Connect the SD card. For UTF8 Support change SdFatConfig.h define USE_UTF8_LONG_NAMES 1.

AudioSource for AudioPlayer using an SD card as data source. This class is based on https://github.com/greiman/SdFat.

Author
Phil Schatzmann

Member Function Documentation

◆ begin() [1/2]

virtual void begin ( )
inlineoverridevirtual

Reset actual stream and move to root.

Implements AudioSource.

◆ begin() [2/2]

virtual void begin ( )
inlineoverridevirtual

Reset actual stream and move to root.

Implements AudioSource.

◆ index() [1/2]

int index ( )
inlinevirtual

Provides the current index position.

Reimplemented from AudioSource.

◆ index() [2/2]

int index ( )
inlinevirtual

Provides the current index position.

Reimplemented from AudioSource.

◆ isAutoNext() [1/2]

virtual bool isAutoNext ( )
inlinevirtual

Returns default setting go to the next.

Reimplemented from AudioSource.

◆ isAutoNext() [2/2]

virtual bool isAutoNext ( )
inlinevirtual

Returns default setting go to the next.

Reimplemented from AudioSource.

◆ nextStream() [1/2]

virtual Stream * nextStream ( int  offset)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ nextStream() [2/2]

virtual Stream * nextStream ( int  offset = 1)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ previousStream()

virtual Stream * previousStream ( int  offset)
inlinevirtualinherited

Returns previous audio stream.

Reimplemented in AudioSourceURL.

◆ selectStream() [1/4]

virtual Stream * selectStream ( const char *  path)
inlineoverridevirtual

Returns audio stream by path.

Implements AudioSource.

◆ selectStream() [2/4]

virtual Stream * selectStream ( const char *  path)
inlineoverridevirtual

Returns audio stream by path.

Implements AudioSource.

◆ selectStream() [3/4]

virtual Stream * selectStream ( int  index)
inlineoverridevirtual

Returns audio stream at the indicated index (the index is zero based, so the first value is 0!)

Reimplemented from AudioSource.

◆ selectStream() [4/4]

virtual Stream * selectStream ( int  index)
inlineoverridevirtual

Returns audio stream at the indicated index (the index is zero based, so the first value is 0!)

Reimplemented from AudioSource.

◆ setFileFilter()

void setFileFilter ( const char *  filter)
inline

Defines the regex filter criteria for selecting files. E.g. ".*Bob Dylan.*"

◆ setTimeout()

virtual void setTimeout ( int  millisec)
inlinevirtual

Sets the timeout of Stream in milliseconds.

Reimplemented from AudioSource.

◆ setTimeoutAutoNext()

virtual void setTimeoutAutoNext ( int  millisec)
inlinevirtualinherited

Sets the timeout which is triggering to move to the next stream. - the default value is 500 ms

◆ size()

long size ( )
inline

Provides the number of files (The max index is size()-1): WARNING this is very slow if you have a lot of files in many subdirectories

◆ toStr() [1/2]

const char * toStr ( )
inlinevirtual

provides the actual file name

Reimplemented from AudioSource.

◆ toStr() [2/2]

const char * toStr ( )
inlinevirtual

provides the actual file name

Reimplemented from AudioSource.


The documentation for this class was generated from the following files: