|
arduino-audio-tools
|
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>
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 |
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):
process_audio_info = false to skip the handshake entirely.process_audio_info setting, not by whether a header has already been received – so it keeps reinterpreting any packet of exactly sizeof(AudioInfo) bytes as a fresh header for the life of the stream. With the default max_size = 200, ordinary audio packets are always ~200 bytes so this is unlikely to misfire in practice, but it becomes a real risk if max_size is ever configured close to sizeof(AudioInfo).cfg.max_size, a constant, rather than reflecting whether a packet has actually arrived or whether the radio is free.ss/rst/dio0 as short, generic macros in the global namespace – ss in particular (a very common local variable name, e.g. std::stringstream ss) is likely to collide with unrelated code that includes this header.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, EncodedAudioOutput, EncodedAudioStream, AACDecoderFDK, DecoderBasic, CodecChain, MP3DecoderHelix, MP3DecoderMAD, OggContainerDecoder, RTSPClient< TcpClient, UdpSocket >, Pipeline, and Pipeline::ModifyingStreamAdapter.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in MP3EncoderShine, PureDataStream, PWMAudioOutput< PWMDriverT >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlinevirtual |
Reimplemented from BaseStream.
|
inlinevirtual |
Reimplemented from BaseStream.
|
inlinevirtual |
Reimplemented from BaseStream.
|
inline |
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inline |
|
inlinevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, ReformatBaseStream, AudioStreamWrapper, ResampleStream, EncodedAudioStream, URLStream, BufferedTaskStream, I2SStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and BufferedStream.
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineprotectedvirtualinherited |
|
inlineprotectedinherited |
|
inlinevirtualinherited |
|
inlineprotected |
|
inlinevirtual |
Reimplemented from AudioStream.
|
inlinevirtualinherited |
Source to generate silence: just sets the buffer to 0.
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlinevirtual |
Defines the input AudioInfo.
Reimplemented from AudioStream.
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlineinherited |
|
inlinevirtual |
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
inlineprotected |
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |