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

TfLiteAudioStream which uses Tensorflow Light to analyze the data. If it is used as a generator (where we read audio data) More...

#include <TfLiteAudioStream.h>

Inheritance diagram for TfLiteAudioStream:
TfLiteAudioStreamBase AudioStream BaseStream AudioInfoSupport AudioInfoSource Stream Print

Public Member Functions

virtual void addNotifyAudioChange (AudioInfoSupport &bi)
 Adds target to be notified about audio changes.
 
virtual AudioInfo audioInfo () override
 provides the actual input AudioInfo
 
virtual AudioInfo audioInfoOut ()
 provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
 
virtual int available () override
 We can provide only some audio data when cfg.input is defined.
 
virtual int availableForWrite () override
 
virtual int availableToWrite () override
 Constant streaming.
 
virtual bool begin ()
 
virtual bool begin (TfLiteConfig config) override
 Start the processing.
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
TfLiteConfigconfig () override
 Provides the TfLiteConfig information.
 
virtual TfLiteConfig defaultConfig () override
 
virtual void end ()
 
virtual void flush () override
 
tflite::MicroInterpreter & interpreter () override
 Provides the tf lite interpreter.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
int8_tmodelInputBuffer () override
 Provides access to the model input buffer.
 
virtual operator bool ()
 
virtual size_t readBytes (uint8_t *data, size_t len) override
 provide audio data with cfg.input
 
virtual size_t readSilence (uint8_t *buffer, size_t length)
 Source to generate silence: just sets the buffer to 0.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
virtual void setAudioInfo (AudioInfo newInfo) override
 Defines the input AudioInfo.
 
void setInterpreter (tflite::MicroInterpreter *p_interpreter)
 Optionally define your own p_interpreter.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
virtual size_t write (const uint8_t *data, size_t len) override
 process the data in batches of max kMaxAudioSampleSize.
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 Writes len bytes of silence (=0).
 

Protected Member Functions

virtual int not_supported (int out, const char *msg="")
 
void notifyAudioChange (AudioInfo info)
 
void refillReadBuffer ()
 
virtual bool setModel (const unsigned char *model)
 
virtual bool setupInterpreter ()
 
virtual bool setupWriter ()
 

Protected Attributes

int _timeout = 10
 
TfLiteConfig cfg
 
AudioInfo info
 
bool is_notify_active = true
 
bool is_setup = false
 
Vector< AudioInfoSupport * > notify_vector
 
tflite::MicroInterpreter * p_interpreter = nullptr
 
const tflite::Model * p_model = nullptr
 
TfLiteTensorp_tensor = nullptr
 
uint8_tp_tensor_arena = nullptr
 
int8_tp_tensor_buffer = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 

Detailed Description

TfLiteAudioStream which uses Tensorflow Light to analyze the data. If it is used as a generator (where we read audio data)

Author
Phil Schatzmann

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

virtual int available ( )
inlineoverridevirtual

We can provide only some audio data when cfg.input is defined.

Reimplemented from BaseStream.

◆ availableForWrite()

virtual int availableForWrite ( )
inlineoverridevirtualinherited

◆ availableToWrite()

virtual int availableToWrite ( )
inlineoverridevirtual

Constant streaming.

Implements TfLiteAudioStreamBase.

◆ begin() [1/2]

virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/2]

virtual bool begin ( TfLiteConfig  config)
inlineoverridevirtual

Start the processing.

Implements TfLiteAudioStreamBase.

◆ config()

TfLiteConfig & config ( )
inlineoverridevirtual

Provides the TfLiteConfig information.

Implements TfLiteAudioStreamBase.

◆ defaultConfig()

virtual TfLiteConfig defaultConfig ( )
inlineoverridevirtual

Implements TfLiteAudioStreamBase.

◆ end()

virtual void end ( )
inlinevirtualinherited

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

Reimplemented from Print.

Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.

◆ interpreter()

tflite::MicroInterpreter & interpreter ( )
inlineoverridevirtual

Provides the tf lite interpreter.

Implements TfLiteAudioStreamBase.

◆ modelInputBuffer()

int8_t * modelInputBuffer ( )
inlineoverridevirtual

Provides access to the model input buffer.

Implements TfLiteAudioStreamBase.

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

Reimplemented in A2DPStream, Pipeline, I2SStream, and MemoryStream.

◆ readBytes()

virtual size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

provide audio data with cfg.input

Reimplemented from AudioStream.

◆ setAudioInfo()

virtual void setAudioInfo ( AudioInfo  info)
inlineoverridevirtualinherited

◆ setInterpreter()

void setInterpreter ( tflite::MicroInterpreter *  p_interpreter)
inlinevirtual

Optionally define your own p_interpreter.

Implements TfLiteAudioStreamBase.

◆ write() [1/2]

virtual size_t write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtual

process the data in batches of max kMaxAudioSampleSize.

Implements TfLiteAudioStreamBase.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in BufferedTaskStream, and BufferedStream.


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