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

SPI master which streams audio to a SPIRegAudioSlave (based on the TinySPISlave library) using its register map: it defines the AudioInfo and the mime type and writes the audio data according to the space which is reported by the available-space register. More...

#include <SPIRegAudioMaster.h>

Inheritance diagram for SPIRegAudioMaster:
Inheritance graph
[legend]
Collaboration diagram for SPIRegAudioMaster:
Collaboration graph
[legend]

Public Member Functions

 SPIRegAudioMaster ()=default
 
 SPIRegAudioMaster (SPIClass &spi)
 
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 ()
 
int availableForWrite () override
 Free space in the slave's audio buffer in bytes.
 
virtual bool begin ()
 
virtual bool begin (AudioInfo info)
 
bool begin (SPIRegAudioMasterConfig cfg=SPIRegAudioMasterConfig())
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
void end ()
 
virtual void flush ()
 
bool isActive () const
 
virtual bool isDeletable ()
 If true we need to release the related memory in the destructor.
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
AudioInfo readAudioInfo ()
 Reads the audio format which is currently defined on the slave.
 
virtual bool removeNotifyAudioChange (AudioInfoSupport &bi)
 Removes a target in order not to be notified about audio changes.
 
void setAudioInfo (AudioInfo info) override
 Defines the audio format on the slave.
 
bool setMime (const char *mime)
 Defines the mime type (max 31 characters) on the slave.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
size_t write (const uint8_t *data, size_t len) override
 
virtual size_t write (uint8_t ch) override
 
virtual void writeSilence (size_t len)
 

Protected Member Functions

void deselect ()
 
void notifyAudioChange (AudioInfo info)
 
bool readRegister (uint8_t addr, uint8_t *out, size_t len)
 Read request frame, pause, reply frame.
 
void select ()
 
bool writeRegister (uint8_t addr, const uint8_t *data, size_t len)
 Write frame: [addr][bytes...].
 

Protected Attributes

int _timeout = 10
 
bool active = false
 
AudioInfo cfg
 
SPIRegAudioMasterConfig config
 
bool is_active = false
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
SPIClass * p_spi = nullptr
 
SingleBuffer< uint8_t > tmp {MAX_SINGLE_CHARS}
 
int tmpPos = 0
 
Vector< uint8_t > tx {0}
 

Detailed Description

SPI master which streams audio to a SPIRegAudioSlave (based on the TinySPISlave library) using its register map: it defines the AudioInfo and the mime type and writes the audio data according to the space which is reported by the available-space register.

master.begin(cfg);
master.setMime("audio/pcm");
master.write(data, len);
AudioInfo cfg
Definition AudioOutput.h:88
SPI master which streams audio to a SPIRegAudioSlave (based on the TinySPISlave library) using its re...
Definition SPIRegAudioMaster.h:48
size_t write(const uint8_t *data, size_t len) override
Definition SPIRegAudioMaster.h:122
bool setMime(const char *mime)
Defines the mime type (max 31 characters) on the slave.
Definition SPIRegAudioMaster.h:76
bool begin(SPIRegAudioMasterConfig cfg=SPIRegAudioMasterConfig())
Definition SPIRegAudioMaster.h:53
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:58
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:60
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:62
Configuration for SPIRegAudioMaster.
Definition SPIRegAudioMaster.h:15

Constructor & Destructor Documentation

◆ SPIRegAudioMaster() [1/2]

SPIRegAudioMaster ( )
default

◆ SPIRegAudioMaster() [2/2]

SPIRegAudioMaster ( SPIClass &  spi)
inlineexplicit

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport &  bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

provides the actual input AudioInfo

Implements AudioInfoSupport.

Reimplemented in AdapterPrintToAudioOutput, EncodedAudioOutput, and AdapterAudioStreamToAudioOutput.

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ availableForWrite()

int availableForWrite ( )
inlineoverridevirtual

Free space in the slave's audio buffer in bytes.

Reimplemented from AudioOutput.

◆ begin() [1/3]

virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/3]

virtual bool begin ( AudioInfo  info)
inlinevirtualinherited

◆ begin() [3/3]

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ deselect()

void deselect ( )
inlineprotected

◆ end()

void end ( )
inlinevirtual

Reimplemented from AudioOutput.

◆ flush()

virtual void flush ( )
inlinevirtualinherited

Reimplemented from Print.

Reimplemented in MultiOutput, and HexDumpOutput.

◆ isActive()

bool isActive ( ) const
inline

◆ isDeletable()

virtual bool isDeletable ( )
inlinevirtualinherited

If true we need to release the related memory in the destructor.

Reimplemented in AdapterPrintToAudioOutput, and AdapterAudioStreamToAudioOutput.

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readAudioInfo()

AudioInfo readAudioInfo ( )
inline

Reads the audio format which is currently defined on the slave.

◆ readRegister()

bool readRegister ( uint8_t  addr,
uint8_t *  out,
size_t  len 
)
inlineprotected

Read request frame, pause, reply frame.

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport &  bi)
inlinevirtualinherited

Removes a target in order not to be notified about audio changes.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ select()

void select ( )
inlineprotected

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlineoverridevirtual

Defines the audio format on the slave.

Reimplemented from AudioOutput.

◆ setMime()

bool setMime ( const char *  mime)
inline

Defines the mime type (max 31 characters) on the slave.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

Deactivate/Reactivate automatic AudioInfo updates: (default is active)

◆ write() [1/2]

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

Writes the audio data; returns the number of bytes which were accepted (all of them in blocking mode)

Implements AudioOutput.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Reimplemented in MetaDataOutput, and MultiOutput.

◆ writeRegister()

bool writeRegister ( uint8_t  addr,
const uint8_t *  data,
size_t  len 
)
inlineprotected

Write frame: [addr][bytes...].

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes n 0 values (= silence)

Parameters
len

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ active

bool active = false
protected

◆ cfg

AudioInfo cfg
protectedinherited

◆ config

SPIRegAudioMasterConfig config
protected

◆ is_active

bool is_active = false
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ p_spi

SPIClass* p_spi = nullptr
protected

◆ tmp

SingleBuffer<uint8_t> tmp {MAX_SINGLE_CHARS}
protectedinherited

◆ tmpPos

int tmpPos = 0
protectedinherited

◆ tx

Vector<uint8_t> tx {0}
protected

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