|
arduino-audio-tools
|
SPI audio slave based on the TinySPISlave library: the master controls us via a small register map (see SPIRegAudioRegisters.h): More...
#include <SPIRegAudioSlave.h>


Public Member Functions | |
| SPIRegAudioSlave (BaseBuffer< uint8_t > &buffer) | |
| 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 () override |
| Readable audio bytes. | |
| int | availableForWrite () override |
| Free space in the buffer: this is the value provided to the master. | |
| virtual bool | begin () |
| bool | begin (SPIRegAudioSlaveConfig cfg=SPIRegAudioSlaveConfig()) |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| void | end () override |
| virtual void | flush () override |
| bool | isActive () const |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| const char * | mime () override |
| const char * | mimeType () |
| Mime type defined by the master (empty if not set) | |
| virtual | operator bool () |
| uint32_t | overflowBytes () const |
| Number of audio bytes dropped because the master ignored the flow control. | |
| size_t | readBytes (uint8_t *data, size_t len) override |
| 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 | setMimeCallback (void(*cb)(const char *mime, void *ctx), void *ctx=nullptr) |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| void | setWriteBufferSize (int size) |
| void | update () |
| Call from loop(): applies AudioInfo / mime changes made by the master. | |
| virtual 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) |
| Writes len bytes of silence (=0). | |
Protected Member Functions | |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | onFrame (size_t len) |
| Processes one frame: runs in ISR / SPI task context! | |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| void | stageReply (uint8_t addr, size_t want) |
| void | storeWrite (uint8_t addr, size_t len) |
Static Protected Member Functions | |
| static void | decodeInfo (const uint8_t *in, AudioInfo &out) |
| static void | encodeInfo (const AudioInfo &in, uint8_t *out) |
| static void | frameThunk (size_t len, void *self) |
Protected Attributes | |
| int | _timeout = 10 |
| bool | active = false |
| SPIRegAudioSlaveConfig | config |
| AudioInfo | info |
| uint8_t | info_raw [SPIREG_AUDIO_INFO_SIZE] |
| bool | is_notify_active = true |
| void(* | mime_cb )(const char *, void *) = nullptr |
| void * | mime_ctx = nullptr |
| char | mime_raw [SPIREG_MIME_SIZE] |
| char | mime_str [SPIREG_MIME_SIZE] = {0} |
| Vector< AudioInfoSupport * > | notify_vector |
| volatile uint32_t | overflow_bytes = 0 |
| BaseBuffer< uint8_t > * | p_buffer = nullptr |
| volatile bool | pending_info = false |
| volatile bool | pending_mime = false |
| TinySPISlave | spi |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| int | write_buffer_size = MAX_SINGLE_CHARS |
SPI audio slave based on the TinySPISlave library: the master controls us via a small register map (see SPIRegAudioRegisters.h):
The received audio is stored in the provided buffer; read it with readBytes() or copy it to an output with StreamCopy. Call update() from loop(): it applies format changes (AudioInfo notifications) in the application context. The SPI frames themselves are processed in the interrupt (RP2040/STM32) or in the TinySPISlave task (ESP32), so the buffer should be safe for one writer (SPI) and one reader (loop), e.g. a RingBuffer.
|
inline |
|
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, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlineoverridevirtual |
Readable audio bytes.
Reimplemented from BaseStream.
|
inlineoverridevirtual |
Free space in the buffer: this is the value provided to the master.
Reimplemented from BaseStream.
|
inlinevirtualinherited |
Reimplemented in AudioOutputWithCallback, AudioMP34DT05, I2SCodecStream, MozziStream, PureDataStream, SPDIFOutput, VS1053Stream, WM8960Stream, AdaptiveResamplingStream, AudioLoRa, ESPNowStream, USBAudioDeviceBase, USBAudioHostBase, VBANStream, FrequencyDetectorAutoCorrelation, GoertzelStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, I2SStream, AudioTimeSourceStream, AudioStreamWrapper, TimerCallbackAudioStream, ResampleStreamT< TInterpolator >, FileLoopT< FileType >, FileLoopT< File >, EncodedAudioStream, AudioBoardStream, AudioKitStream, MiniAudioStream, PortAudioStream, StdioStream, HLSStreamT< URLStream >, NRF24Stream, ReedSolomonFEC< bytecount, additional_bytes >, AutomaticGainControlStream, MeasuringStream, QualityAnalysisStream, VolumeStream, AnalogAudioStream, AdapterAudioOutputToAudioStream, TimedStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, ProgressStream, Throttle, InputMerge< T >, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, VolumeMeter, AudioInputMonitor, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, CatStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, Pipeline, Pipeline::ModifyingStreamAdapter, ResampleStream, SupportedRatesStream, AudioFFTBase, and EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >.
|
inline |
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, ReformatBaseStream, AudioStreamWrapper, ResampleStream, EncodedAudioStream, BLESerialClientBase, URLStream, BufferedTaskStream, AutomaticGainControlStream, MeasuringStream, QualityAnalysisStream, VolumeStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, I2SStream, TimedStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, QueueStream< T >, QueueStream< uint8_t >, FadeStream, Pipeline::ModifyingStreamAdapter, SupportedRatesStream, and EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >.
|
inlinestaticprotected |
|
inline |
|
inlineoverridevirtual |
Mime type defined by the master (nullptr if not set): this allows to use the slave as source for the MultiDecoder
Implements MimeSource.
|
inline |
Mime type defined by the master (empty if not set)
|
inlineprotectedinherited |
|
inlineprotected |
Processes one frame: runs in ISR / SPI task context!
|
inlinevirtualinherited |
|
inline |
Number of audio bytes dropped because the master ignored the flow control.
Reimplemented from AudioStream.
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 >.
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in VS1053Stream, WM8960Stream, AutomaticGainControlStream, VolumeStream, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, MiniAudioStream, PortAudioStream, I2SCodecStream, MozziStream, SPDIFOutput, AudioLoRa, AnalogAudioStream, I2SStream, TimerCallbackAudioStream, MDFEchoCancellationStream< T, SampleType >, AudioKitStream, NRF24Stream, SPIAudioSlave, USBAudioDeviceBase, USBAudioHostBase, VBANStream, GoertzelStream, MeasuringStream, QualityAnalysisStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, AdapterAudioOutputToAudioStream, TimedStream, ProgressStream, CallbackStream, VolumeMeter, AudioInputMonitor, FormatConverterStream, FadeStream, Pipeline::ModifyingStreamAdapter, AudioFFTBase, EncodedAudioStream, PureDataStream, BLESerialStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, Pipeline, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inline |
Callback which is called from update() when the master has defined a (new) mime type: e.g. to restart the decoder
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlineinherited |
Implements BaseStream.
Reimplemented in URLStream, LMSEchoCancellationStream< T >, MDFEchoCancellationStream< T, SampleType >, ESP3288AudioOutput, I2SCodecStream, MozziStream, PureDataStream, SPDIFOutput, AudioLoRa, USBAudioStreamBase, I2SStream, AudioStreamWrapper, ConverterStream< T >, EncodedAudioStream, FaustStream< DSP >, AudioKitStream, MiniAudioStream, PortAudioStream, TfLiteAudioStream, VS1053Stream, A2DPStream, AdaptiveResamplingStream, BLESerialServerBase, BLESerialClientBase, BufferedTaskStream, URLStreamESP32, NRF24Stream, SPIAudioSlave, VBANStream, AutomaticGainControlStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, GoertzelStream, MeasuringStream, QualityAnalysisStream, VolumeStream, AnalogAudioStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3BandsT< T >, Equalizer3BandsPerChannelT< T >, AdapterAudioOutputToAudioStream, TimedStream, AudioTimeSourceStream, MemoryStream, RingBufferStream, BufferedStream, ProgressStream, Throttle, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, VolumeMeter, AudioInputMonitor, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, FadeStream, Pipeline, Pipeline::ModifyingStreamAdapter, ResampleStream, ResampleStreamT< TInterpolator >, SupportedRatesStream, AudioFFTBase, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, TfLiteAudioStreamBase, WM8960Stream, AnalogDriverESP32V1::IO16Bit, and AnalogDriverESP32V2::IO16Bit.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |