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

Sends and receives audio over a LoRa radio link (via the sandeepmistry/arduino-LoRa library) as a regular AudioTools Stream, so it can be dropped into a StreamCopy pipeline like any other audio source/sink – e.g. StreamCopy(audioLoRa, i2sMic) to transmit, or StreamCopy(i2sSpeaker, audioLoRa) to receive. See AudioLoRaConfig's documentation first for why, even with its audio-tuned defaults, this only works at all in a narrow envelope (very low bitrate, short clips/bursts). More...

#include <AudioLoRa.h>

Inheritance diagram for AudioLoRa:
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 ()
 
int available ()
 
int availableForWrite ()
 
bool begin ()
 
bool begin (AudioLoRaConfig config)
 
virtual void clearNotifyAudioChange ()
 Deletes all change notify subscriptions.
 
AudioLoRaConfig defaultConfig ()
 
void end ()
 
virtual void flush () override
 
bool isNotifyActive ()
 Checks if the automatic AudioInfo update is active.
 
virtual operator bool ()
 
size_t readBytes (uint8_t *data, size_t len)
 
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.
 
void setAudioInfo (AudioInfo info)
 Defines the input AudioInfo.
 
void setNotifyActive (bool flag)
 Deactivate/Reactivate automatic AudioInfo updates: (default is active)
 
void setWriteBufferSize (int size)
 
size_t write (const uint8_t *data, size_t len)
 
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 readAudioInfo ()
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 
void writeAudioInfo ()
 

Protected Attributes

int _timeout = 10
 
SingleBuffer< uint8_t > buffer
 
AudioLoRaConfig cfg
 
AudioInfo info
 
bool is_notify_active = true
 
Vector< AudioInfoSupport * > notify_vector
 
RingBuffer< uint8_t > tmp_in {0}
 
RingBuffer< uint8_t > tmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

Sends and receives audio over a LoRa radio link (via the sandeepmistry/arduino-LoRa library) as a regular AudioTools Stream, so it can be dropped into a StreamCopy pipeline like any other audio source/sink – e.g. StreamCopy(audioLoRa, i2sMic) to transmit, or StreamCopy(i2sSpeaker, audioLoRa) to receive. See AudioLoRaConfig's documentation first for why, even with its audio-tuned defaults, this only works at all in a narrow envelope (very low bitrate, short clips/bursts).

Wire protocol: if cfg.process_audio_info is set (the default), begin() sends a single LoRa packet containing a raw AudioInfo struct (sample rate/channels/bits) right away, so a receiver can learn the format instead of needing it configured out of band. From then on, write() appends audio bytes to an internal buffer and transmits one LoRa packet each time it fills to cfg.max_size. On the receiving side, readBytes() checks each incoming packet's size and, whenever it matches sizeof(AudioInfo), decodes it as a header via setAudioInfo() instead of returning it as audio payload.

Known limitations (review notes, not yet fixed):

Note
Supported only on Arduino platforms with LoRa support (e.g. ESP32) and the LoRa library!
Requires: 👉 https://github.com/sandeepmistry/arduino-LoRa
Author
Phil Schatzmann

Member Function Documentation

◆ addNotifyAudioChange()

virtual void addNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

◆ audioInfo()

virtual AudioInfo audioInfo ( )
inlineoverridevirtualinherited

◆ audioInfoOut()

virtual AudioInfo audioInfoOut ( )
inlinevirtualinherited

◆ available()

int available ( )
inlinevirtual

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlinevirtual

Reimplemented from BaseStream.

◆ begin() [1/2]

bool begin ( )
inlinevirtual

Reimplemented from BaseStream.

◆ begin() [2/2]

bool begin ( AudioLoRaConfig  config)
inline

◆ clearNotifyAudioChange()

virtual void clearNotifyAudioChange ( )
inlinevirtualinherited

Deletes all change notify subscriptions.

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ defaultConfig()

AudioLoRaConfig defaultConfig ( )
inline

◆ end()

void end ( )
inlinevirtual

Reimplemented from BaseStream.

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ isNotifyActive()

bool isNotifyActive ( )
inlineinherited

Checks if the automatic AudioInfo update is active.

◆ not_supported()

virtual int not_supported ( int  out,
const char *  msg = "" 
)
inlineprotectedvirtualinherited

◆ notifyAudioChange()

void notifyAudioChange ( AudioInfo  info)
inlineprotectedinherited

◆ operator bool()

virtual operator bool ( )
inlinevirtualinherited

◆ readAudioInfo()

void readAudioInfo ( )
inlineprotected

◆ readBytes()

size_t readBytes ( uint8_t *  data,
size_t  len 
)
inlinevirtual

Reimplemented from AudioStream.

◆ readSilence()

virtual size_t readSilence ( uint8_t *  buffer,
size_t  length 
)
inlinevirtualinherited

Source to generate silence: just sets the buffer to 0.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

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

◆ removeNotifyAudioChange()

virtual bool removeNotifyAudioChange ( AudioInfoSupport bi)
inlinevirtualinherited

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

Reimplemented in RTSPClient< TcpClient, UdpSocket >.

◆ setAudioInfo()

void setAudioInfo ( AudioInfo  info)
inlinevirtual

Defines the input AudioInfo.

Reimplemented from AudioStream.

◆ setNotifyActive()

void setNotifyActive ( bool  flag)
inlineinherited

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

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ write() [1/2]

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

Reimplemented from AudioStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

◆ writeAudioInfo()

void writeAudioInfo ( )
inlineprotected

◆ writeSilence()

virtual void writeSilence ( size_t  len)
inlinevirtualinherited

Writes len bytes of silence (=0).

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ buffer

SingleBuffer<uint8_t> buffer
protected

◆ cfg

AudioLoRaConfig cfg
protected

◆ info

AudioInfo info
protectedinherited

◆ is_notify_active

bool is_notify_active = true
protectedinherited

◆ notify_vector

Vector<AudioInfoSupport*> notify_vector
protectedinherited

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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