arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AudioSourceIdxSDFAT< AudioFs, AudioFile > Class Template Reference

ESP32 AudioSource for AudioPlayer using an SD card as data source. An index file is used to speed up the access to the audio files by index. This class is based on the Arduino SD implementation For UTF8 Support change SdFatConfig.h define USE_UTF8_LONG_NAMES 1. More...

#include <AudioSourceIdxSDFAT.h>

Inheritance diagram for AudioSourceIdxSDFAT< AudioFs, AudioFile >:
AudioSource

Public Member Functions

 AudioSourceIdxSDFAT (AudioFs fs, const char *startFilePath="/", const char *ext="", bool setupIndex=true)
 Constructor for providing an open FS.
 
 AudioSourceIdxSDFAT (const char *startFilePath, const char *ext, SdSpiConfig &config, bool setupIndex=true)
 Costructor with SdSpiConfig.
 
 AudioSourceIdxSDFAT (const char *startFilePath="/", const char *ext=".mp3", int chipSelect=PIN_CS, int speedMHz=10, bool setupIndex=true)
 Default constructor.
 
virtual ~AudioSourceIdxSDFAT ()
 
virtual bool begin () override
 Reset actual stream and move to root.
 
void end ()
 
int index ()
 Provides the current index position.
 
int indexOf (const char *filename)
 Provides the index of the file with the given name.
 
virtual bool isAutoNext ()
 Returns default setting go to the next.
 
const charname (int pos)
 Provides the file name for the indicated index.
 
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: The index is not changed!
 
virtual StreamselectStream (int index) override
 
virtual void setAutoNext (bool flag)
 
void setCreateIndex (bool rebuild)
 Defines whether the index should be rebuild on begin.
 
void setFileFilter (const char *filter)
 
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 setTimeout (int millisec)
 Sets the timeout of Stream in milliseconds.
 
virtual void setTimeoutAutoNext (int millisec)
 
long size ()
 Provides the number of files (The max index is size()-1)
 
virtual int timeoutAutoNext ()
 Provides the timeout which is triggering to move to the next stream.
 
const chartoStr ()
 provides the actual file name
 

Protected Member Functions

const chargetFileName (AudioFile &file)
 

Protected Attributes

int cs
 
const charexension = nullptr
 
AudioFile file
 
char file_name [MAX_FILE_LEN]
 
const charfile_name_pattern = "*"
 
SDIndex< AudioFs, AudioFileidx {sd}
 
size_t idx_pos = 0
 
bool is_auto_next = true
 
bool is_close_sd = true
 
bool is_sd_setup = false
 
bool owns_cfg = false
 
SdSpiConfigp_cfg = nullptr
 
AudioFs sd
 
bool setup_index = true
 
const charstart_path = nullptr
 
int timeout_auto_next_value = 500
 

Detailed Description

template<typename AudioFs = SdFat32, typename AudioFile = File32>
class audio_tools::AudioSourceIdxSDFAT< AudioFs, AudioFile >

ESP32 AudioSource for AudioPlayer using an SD card as data source. An index file is used to speed up the access to the audio files by index. This class is based on the Arduino SD implementation For UTF8 Support change SdFatConfig.h define USE_UTF8_LONG_NAMES 1.

Parameters
<SdFat32,File32>,<SdFs,FsFile>,<SdExFat,ExFile>,<SdFat,File>
Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ AudioSourceIdxSDFAT() [1/3]

template<typename AudioFs = SdFat32, typename AudioFile = File32>
AudioSourceIdxSDFAT ( const char startFilePath = "/",
const char ext = ".mp3",
int  chipSelect = PIN_CS,
int  speedMHz = 10,
bool  setupIndex = true 
)
inline

Default constructor.

◆ AudioSourceIdxSDFAT() [2/3]

template<typename AudioFs = SdFat32, typename AudioFile = File32>
AudioSourceIdxSDFAT ( const char startFilePath,
const char ext,
SdSpiConfig config,
bool  setupIndex = true 
)
inline

Costructor with SdSpiConfig.

◆ AudioSourceIdxSDFAT() [3/3]

template<typename AudioFs = SdFat32, typename AudioFile = File32>
AudioSourceIdxSDFAT ( AudioFs  fs,
const char startFilePath = "/",
const char ext = "",
bool  setupIndex = true 
)
inline

Constructor for providing an open FS.

◆ ~AudioSourceIdxSDFAT()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual ~AudioSourceIdxSDFAT ( )
inlinevirtual

Member Function Documentation

◆ begin()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual bool begin ( )
inlineoverridevirtual

Reset actual stream and move to root.

Implements AudioSource.

◆ end()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
void end ( )
inline

◆ getFileName()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char * getFileName ( AudioFile file)
inlineprotected

◆ index()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
int index ( )
inlinevirtual

Provides the current index position.

Reimplemented from AudioSource.

◆ indexOf()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
int indexOf ( const char filename)
inline

Provides the index of the file with the given name.

◆ isAutoNext()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual bool isAutoNext ( )
inlinevirtual

Returns default setting go to the next.

Reimplemented from AudioSource.

◆ name()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char * name ( int  pos)
inline

Provides the file name for the indicated index.

◆ nextStream()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual Stream * nextStream ( int  offset = 1)
inlineoverridevirtual

Returns next audio stream.

Implements AudioSource.

◆ operator[]()

Stream * operator[] ( int  idx)
inlineinherited

access with array syntax

◆ previousStream()

virtual Stream * previousStream ( int  offset)
inlinevirtualinherited

Returns previous audio stream.

Reimplemented in AudioSourceFTP< ClientType >, and AudioSourceURL.

◆ selectStream() [1/2]

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual Stream * selectStream ( const char path)
inlineoverridevirtual

Returns audio stream by path: The index is not changed!

Implements AudioSource.

◆ selectStream() [2/2]

template<typename AudioFs = SdFat32, typename AudioFile = File32>
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.

◆ setAutoNext()

virtual void setAutoNext ( bool  flag)
inlinevirtualinherited

Reimplemented in AudioSourceCallback.

◆ setCreateIndex()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
void setCreateIndex ( bool  rebuild)
inline

Defines whether the index should be rebuild on begin.

◆ setFileFilter()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
void setFileFilter ( const char filter)
inline

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

◆ setIndex()

virtual Stream * setIndex ( int  index)
inlinevirtualinherited

same as selectStream - I just prefer this name

◆ setMetadataCallback()

virtual bool setMetadataCallback ( void(*)(MetaDataType info, const char *str, int len)  fn,
ID3TypeSelection  sel = SELECT_ICY 
)
inlinevirtualinherited

Reimplemented in AudioSourceURL.

◆ setPath()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
virtual void setPath ( const char p)
inlinevirtual

Allows to "correct" the start path if not defined in the constructor.

◆ setTimeout()

virtual void setTimeout ( int  millisec)
inlinevirtualinherited

Sets the timeout of Stream in milliseconds.

Reimplemented in AudioSourceURL, and AudioSourceSDFAT< AudioFs, AudioFile >.

◆ 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()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
long size ( )
inline

Provides the number of files (The max index is size()-1)

◆ timeoutAutoNext()

virtual int timeoutAutoNext ( )
inlinevirtualinherited

Provides the timeout which is triggering to move to the next stream.

◆ toStr()

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char * toStr ( )
inlinevirtual

provides the actual file name

Reimplemented from AudioSource.

Member Data Documentation

◆ cs

template<typename AudioFs = SdFat32, typename AudioFile = File32>
int cs
protected

◆ exension

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char* exension = nullptr
protected

◆ file

template<typename AudioFs = SdFat32, typename AudioFile = File32>
AudioFile file
protected

◆ file_name

template<typename AudioFs = SdFat32, typename AudioFile = File32>
char file_name[MAX_FILE_LEN]
protected

◆ file_name_pattern

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char* file_name_pattern = "*"
protected

◆ idx

template<typename AudioFs = SdFat32, typename AudioFile = File32>
SDIndex<AudioFs, AudioFile> idx {sd}
protected

◆ idx_pos

template<typename AudioFs = SdFat32, typename AudioFile = File32>
size_t idx_pos = 0
protected

◆ is_auto_next

bool is_auto_next = true
protectedinherited

◆ is_close_sd

template<typename AudioFs = SdFat32, typename AudioFile = File32>
bool is_close_sd = true
protected

◆ is_sd_setup

template<typename AudioFs = SdFat32, typename AudioFile = File32>
bool is_sd_setup = false
protected

◆ owns_cfg

template<typename AudioFs = SdFat32, typename AudioFile = File32>
bool owns_cfg = false
protected

◆ p_cfg

template<typename AudioFs = SdFat32, typename AudioFile = File32>
SdSpiConfig* p_cfg = nullptr
protected

◆ sd

template<typename AudioFs = SdFat32, typename AudioFile = File32>
AudioFs sd
protected

◆ setup_index

template<typename AudioFs = SdFat32, typename AudioFile = File32>
bool setup_index = true
protected

◆ start_path

template<typename AudioFs = SdFat32, typename AudioFile = File32>
const char* start_path = nullptr
protected

◆ timeout_auto_next_value

int timeout_auto_next_value = 500
protectedinherited

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