arduino-audio-tools
|
A buffer that reads sample sizes from an M4A file using the M4AAudioFileDemuxer. No RAM is used to store the sample sizes as they are read directly from the file. More...
#include <M4AFileSampleSizeBuffer.h>
Public Member Functions | |
M4AFileSampleSizeBuffer (AudioPlayer &player, ContainerM4A &container, const char *fileExt=".m4a") | |
Constructor. | |
void | addFileExtension (const char *fileExt) |
Add a file extension to recognize as relevant for this buffer. | |
stsz_sample_size_t * | address () override |
Returns a pointer to the buffer's physical address. | |
int | available () |
Returns the number of samples already read (i.e., the current sample index). | |
int | availableForWrite () override |
Returns the available space for writing. | |
void | clear () |
same as reset | |
virtual int | clearArray (int len) |
Removes the next len entries. | |
bool | isEmpty () |
virtual bool | isFull () |
checks if the buffer is full | |
virtual float | levelPercent () |
Returns the level of the buffer in %. | |
bool | peek (stsz_sample_size_t &result) |
Peek is not supported for this buffer. | |
bool | read (stsz_sample_size_t &data) override |
Get the next sample size from the demuxer. | |
virtual int | readArray (stsz_sample_size_t data[], int len) |
reads multiple values | |
void | reset () |
clears the buffer | |
virtual bool | resize (int bytes) |
Resizes the buffer if supported: returns false if not supported. | |
void | setReadBufferSize (size_t size) |
Defines how many samples are buffered with each file read. | |
size_t | size () override |
Returns the total number of samples in the file. | |
bool | write (stsz_sample_size_t data) |
Write is ignored; sample sizes are read directly from the file. | |
virtual int | writeArray (const stsz_sample_size_t data[], int len) |
Fills the buffer data. | |
virtual int | writeArrayOverwrite (const stsz_sample_size_t data[], int len) |
Fills the buffer data and overwrites the oldest data if the buffer is full. | |
Protected Member Functions | |
bool | isRelevantFile (const char *name) |
Checks if the given file name matches any of the registered extensions. | |
Static Protected Member Functions | |
static void | onFileChange (Stream *streamPtr, void *reference) |
Static callback for file change events. Updates the file pointer and re-parses the file if relevant. | |
Protected Attributes | |
M4AAudioFileDemuxer | demuxer |
Demuxer used to extract sample sizes. | |
Vector< const char * > | fileExtensions |
List of recognized file extensions. | |
ContainerM4A * | p_container = nullptr |
File * | p_file = nullptr |
Pointer to the currently open file. | |
AudioPlayer * | p_player = nullptr |
Pointer to the AudioPlayer instance. | |
A buffer that reads sample sizes from an M4A file using the M4AAudioFileDemuxer. No RAM is used to store the sample sizes as they are read directly from the file.
This buffer is designed to be used with an AudioPlayer instance for audio sources which are file based only. It provides a read interface that fetches the next sample size directly from the file via the demuxer, avoiding the need to store the entire sample size table in RAM.
|
inline |
Constructor.
player | Reference to the AudioPlayer instance. |
fileExt | File extension to recognize as M4A (default ".m4a"). |
|
inline |
Add a file extension to recognize as relevant for this buffer.
fileExt | File extension string (e.g., ".m4a"). |
|
inlineoverridevirtual |
Returns a pointer to the buffer's physical address.
Implements BaseBuffer< stsz_sample_size_t >.
|
inlinevirtual |
Returns the number of samples already read (i.e., the current sample index).
Implements BaseBuffer< stsz_sample_size_t >.
|
inlineoverridevirtual |
Returns the available space for writing.
Implements BaseBuffer< stsz_sample_size_t >.
|
inlineprotected |
Checks if the given file name matches any of the registered extensions.
name | File name to check. |
|
inlinestaticprotected |
Static callback for file change events. Updates the file pointer and re-parses the file if relevant.
streamPtr | Pointer to the new file stream. |
reference | Pointer to the M4AFileSampleSizeBuffer instance. |
|
inlinevirtual |
Peek is not supported for this buffer.
result | Reference to store the peeked value (unused). |
Implements BaseBuffer< stsz_sample_size_t >.
|
inlineoverridevirtual |
Get the next sample size from the demuxer.
data | Reference to store the sample size. |
Implements BaseBuffer< stsz_sample_size_t >.
|
inlinevirtual |
clears the buffer
Implements BaseBuffer< stsz_sample_size_t >.
|
inline |
Defines how many samples are buffered with each file read.
size | Number of bytes to buffer (will be divided by 4 for sample count). |
|
inlineoverridevirtual |
Returns the total number of samples in the file.
Implements BaseBuffer< stsz_sample_size_t >.
|
inlinevirtual |
Write is ignored; sample sizes are read directly from the file.
data | Sample size value (ignored). |
Implements BaseBuffer< stsz_sample_size_t >.