arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FileLoop Class Reference

A simple class which implements a automatic looping file. The file needs to be of the class File from FS.h. The number of loops can be defined by calling setLoopCount(). You can also optinally limit the total looping file size by calling setSize();. More...

#include <FileLoop.h>

Inheritance diagram for FileLoop:
FileLoopT< File > BaseStream Stream Print

Public Member Functions

 FileLoop ()=default
 
 FileLoop (File file, int count=-1, int rewindPos=0)
 
int available () override
 
virtual int availableForWrite () override
 
bool begin ()
 
void end ()
 
Filefile ()
 Returns the file.
 
virtual void flush () override
 
bool isLoopActive ()
 
 operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 
void setCallback (void(*cb)(FileLoopT &loop))
 You can be notified about a rewind.
 
void setFile (File file)
 defines the file that is used for looping
 
void setLoopCount (int count)
 
void setRewindPos (int pos)
 defines the start position after the rewind. E.g. for wav files this should be 44
 
void setSize (size_t len)
 optionally defines the requested playing size in bytes
 
void setStartPos (int pos)
 defines the start position at the beginning
 
void setWriteBufferSize (int size)
 
size_t size ()
 Returns the (requested) file size.
 
size_t write (const uint8_t *data, size_t len)
 
virtual size_t write (uint8_t ch) override
 

Protected Member Functions

void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 

Protected Attributes

int _timeout = 10
 
void(* callback )(FileLoopT &loop)
 
File current_file
 
int loop_count
 
int rewind_pos
 
int size_open
 
int start_pos
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int total_size
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

A simple class which implements a automatic looping file. The file needs to be of the class File from FS.h. The number of loops can be defined by calling setLoopCount(). You can also optinally limit the total looping file size by calling setSize();.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ FileLoop() [1/2]

FileLoop ( )
default

◆ FileLoop() [2/2]

FileLoop ( File  file,
int  count = -1,
int  rewindPos = 0 
)
inline

Member Function Documentation

◆ available()

int available ( )
inlineoverridevirtualinherited

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ begin()

bool begin ( )
inlinevirtualinherited

Reimplemented from BaseStream.

◆ end()

void end ( )
inlinevirtualinherited

Reimplemented from BaseStream.

◆ file()

File & file ( )
inlineinherited

Returns the file.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ isLoopActive()

bool isLoopActive ( )
inlineinherited
Returns
true as long as we are looping

◆ operator bool()

operator bool ( )
inlineinherited

◆ readBytes()

size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlineoverridevirtualinherited

Implements BaseStream.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ setCallback()

void setCallback ( void(*)(FileLoopT< File > &loop cb)
inlineinherited

You can be notified about a rewind.

◆ setFile()

void setFile ( File  file)
inlineinherited

defines the file that is used for looping

◆ setLoopCount()

void setLoopCount ( int  count)
inlineinherited

count values: 0) do not loop, 1) loop once, n) loop n times, -1) loop endless

◆ setRewindPos()

void setRewindPos ( int  pos)
inlineinherited

defines the start position after the rewind. E.g. for wav files this should be 44

◆ setSize()

void setSize ( size_t  len)
inlineinherited

optionally defines the requested playing size in bytes

◆ setStartPos()

void setStartPos ( int  pos)
inlineinherited

defines the start position at the beginning

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ size()

size_t size ( )
inlineinherited

Returns the (requested) file size.

◆ write() [1/2]

size_t write ( const uint8_t *  data,
size_t  len 
)
inlinevirtualinherited

Implements BaseStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ callback

void(* callback) (FileLoopT &loop)
protectedinherited

◆ current_file

File current_file
protectedinherited

◆ loop_count

int loop_count
protectedinherited

◆ rewind_pos

int rewind_pos
protectedinherited

◆ size_open

int size_open
protectedinherited

◆ start_pos

int start_pos
protectedinherited

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ total_size

int total_size
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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