arduino-audio-tools
|
Flexible Audio Data Source using a Vector of (file) names with minimal RAM usage. Files are stored with separated path index and name to minimize memory consumption. Identical paths are stored only once in a shared path registry. This class is a template to support multiple SD libraries and other Streams. More...
#include <AudioSource.h>
Public Types | |
typedef FileType *(* | FileToStreamCallback) (const char *path, FileType &oldFile) |
Public Member Functions | |
AudioSourceVector (FileToStreamCallback callback) | |
Constructor with callback for file to stream conversion. | |
void | addName (const char *nameWithPath) override |
Add a file with full path (path and name will be separated automatically) | |
template<typename T , size_t N> | |
void | addNames (T(&nameArray)[N]) |
Add multiple files at once. | |
virtual void | begin () override |
Reset actual stream and move to root. | |
void | clear () |
Clear all files and path registry. | |
bool | deleteIndex (size_t idx) |
Remove a file by index. | |
bool | deleteName (const char *nameWithPath) |
Remove a file by full path. | |
FileType & | getCurrentFile () |
Get the current file reference for use in callback. | |
virtual int | index () override |
Returns the actual index of the stream. | |
int | indexOf (const char *path) |
Find index of file by path. | |
virtual bool | isAutoNext () |
Returns default setting go to the next. | |
bool | isEmpty () |
Check if empty. | |
const char * | name (int index) |
provides the name at the given index | |
virtual FileType * | nextStream (int offset) override |
Returns next audio stream. | |
Stream * | operator[] (int idx) |
access with array syntax | |
virtual Stream * | previousStream (int offset) |
Returns previous audio stream. | |
virtual FileType * | selectStream (const char *path) override |
Returns audio stream by path. | |
virtual FileType * | selectStream (int index) override |
Returns audio stream at the indicated index. | |
virtual Stream * | setIndex (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) |
void | setNameToStreamCallback (FileToStreamCallback callback) |
Set the callback for converting file path to stream. | |
virtual void | setTimeout (int millisec) |
Sets the timeout of Stream in milliseconds. | |
virtual void | setTimeoutAutoNext (int millisec) |
int | size () |
Get the number of files. | |
virtual int | timeoutAutoNext () |
Provides the timeout which is triggering to move to the next stream. | |
virtual const char * | toStr () override |
provides the actual stream (e.g. file) name or url | |
Protected Member Functions | |
int | findOrAddPath (const char *path) |
Find existing path in registry or add new one, returns index. | |
FileEntry & | getFileEntry (int index) const |
Get file entry at index. | |
Str | getFullPath (int index) |
Get full path of file at index. | |
const char * | getPath (int pathIndex) |
Get path from registry at index. | |
Protected Attributes | |
int | current_index = 0 |
Str | current_path |
FileType * | current_stream = nullptr |
Vector< FileEntry > | files |
FileToStreamCallback | nameToStreamCallback = nullptr |
Vector< Str > | path_registry |
int | timeout_auto_next_value = 500 |
Flexible Audio Data Source using a Vector of (file) names with minimal RAM usage. Files are stored with separated path index and name to minimize memory consumption. Identical paths are stored only once in a shared path registry. This class is a template to support multiple SD libraries and other Streams.
Example callback signature: FileType* callback(const char* path, FileType& oldFile);
Without this callback, the class cannot open or access files for playback. Also don't forget to close the old file to prevent any memory leaks.
|
inlineoverridevirtual |
Add a file with full path (path and name will be separated automatically)
Implements PathNamesRegistry.
|
inlineoverridevirtual |
Reset actual stream and move to root.
Implements AudioSource.
|
inlineoverridevirtual |
Returns the actual index of the stream.
Reimplemented from AudioSource.
|
inlinevirtualinherited |
Returns default setting go to the next.
Reimplemented in AudioSourceIdxSD, AudioSourceIdxSDFAT< AudioFs, AudioFile >, AudioSourceIdxSDMMC, AudioSourceLittleFS, AudioSourceSD, AudioSourceSDFAT< AudioFs, AudioFile >, AudioSourceSDMMC, AudioSourceSPIFFS, AudioSourceSTD, AudioSourceURL, AudioSourceVFS, AudioSourceSDFAT< AudioFs, AudioFile >, and AudioSourceCallback.
|
inlineoverridevirtual |
Returns next audio stream.
Implements AudioSource.
|
inlinevirtualinherited |
Returns previous audio stream.
Reimplemented in AudioSourceFTP< ClientType >, and AudioSourceURL.
|
inlineoverridevirtual |
Returns audio stream by path.
Implements AudioSource.
|
inlineoverridevirtual |
Returns audio stream at the indicated index.
Reimplemented from AudioSource.
|
inlinevirtualinherited |
Sets the timeout of Stream in milliseconds.
Reimplemented in AudioSourceURL, and AudioSourceSDFAT< AudioFs, AudioFile >.
|
inlinevirtualinherited |
Sets the timeout which is triggering to move to the next stream. - the default value is 500 ms
|
inlineoverridevirtual |
provides the actual stream (e.g. file) name or url
Reimplemented from AudioSource.