|
arduino-audio-tools
|
CallbackStream: A Stream that allows to register callback methods for accessing and providing and updating data. The callbacks can be lambda expressions. The update callback can also be used just to read the data without changing it. Warning: this class does not propagate audio info changes to the target stream. You need to do this manually. More...
#include <AudioStreams.h>
Public Member Functions | |
| CallbackStream ()=default | |
| CallbackStream (Print &out, size_t(*cb_update)(uint8_t *data, size_t len)) | |
| Allows to change the audio before sending it to the output. | |
| CallbackStream (size_t(*cb_read)(uint8_t *data, size_t len), size_t(*cb_write)(const uint8_t *data, size_t len)) | |
| CallbackStream (Stream &io, size_t(*cb_update)(uint8_t *data, size_t len)) | |
| 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 |
| virtual int | availableForWrite () override |
| virtual bool | begin () override |
| virtual bool | begin (AudioInfo info) |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| void | end () override |
| 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) 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. | |
| void | setAudioInfo (AudioInfo info) override |
| Updates the audio info and calls the callback. | |
| void | setAudioInfoCallback (void(*cb)(AudioInfo info)) |
| defines the callback to receive the actual audio info | |
| void | setAvailable (int val) |
| optioinally define available bytes for next read | |
| void | setAvailableCallback (int(*cb)()) |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| virtual void | setOutput (AudioOutput &out) |
| Defines/Changes the output target and registers for audio change notifications. | |
| void | setOutput (Print &out) override |
| Defines/Changes the output target. | |
| void | setOutput (Stream &in) |
| same as setStream | |
| void | setReadCallback (size_t(*cb_read)(uint8_t *data, size_t len)) |
| Instead of reading from the input stream we call this method. | |
| virtual void | setStream (AudioStream &io) |
| Defines/Changes the input & output and registers for audio change notifications. | |
| void | setStream (Print &out) |
| same as set Output | |
| void | setStream (Stream &in) override |
| Defines/Changes the input & output. | |
| void | setUpdateCallback (size_t(*cb_update)(uint8_t *data, size_t len)) |
| After Reading or before writing we call this method to allow to modify the data. | |
| void | setWriteBufferSize (int size) |
| void | setWriteCallback (size_t(*cb_write)(const uint8_t *data, size_t len)) |
| Instead of writing to the output stream we call this method. | |
| 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 | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
Protected Attributes | |
| int | _timeout = 10 |
| bool | active = true |
| int | available_bytes = -1 |
| void(* | cb_audio_info )(AudioInfo info) = nullptr |
| int(* | cb_available )() = nullptr |
| size_t(* | cb_read )(uint8_t *data, size_t len) = nullptr |
| size_t(* | cb_update )(uint8_t *data, size_t len) = nullptr |
| size_t(* | cb_write )(const uint8_t *data, size_t len) = nullptr |
| AudioInfo | info |
| bool | is_notify_active = true |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_out = nullptr |
| Stream * | p_stream = nullptr |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| int | write_buffer_size = MAX_SINGLE_CHARS |
CallbackStream: A Stream that allows to register callback methods for accessing and providing and updating data. The callbacks can be lambda expressions. The update callback can also be used just to read the data without changing it. Warning: this class does not propagate audio info changes to the target stream. You need to do this manually.
|
default |
|
inline |
Allows to change the audio before sending it to the output or before getting it from the original input
|
inline |
Allows to change the audio before sending it to the output.
|
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, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in AudioLoRa, UDPStream, VBANStream, AudioStreamWrapper, ConverterStream< T >, EncodedAudioStream, FaustStream< DSP >, I2SCodecStream, MiniAudioStream, StdioStream, A2DPStream, ESPNowStream, HammingFEC< bytecount, block_t >, AbstractURLStream, URLStreamESP32, NRF24Stream, ReedSolomonFEC< bytecount, additional_bytes >, SPIAudioSlave, USBAudioDeviceBase, AnalogAudioStream, AudioEffectStreamT< T >, AudioEffectStream, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, ReformatBaseStream, TimedStream, MemoryStream, RingBufferStream, MeasuringStream, ProgressStream, Throttle, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, FadeStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, Pipeline, QualityAnalysisStream, VolumeStream, AudioFFTBase, AudioBLEClient, AudioBLEClient, AudioBLEServer, and AudioBLEServer.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlinevirtual |
|
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, URLStream, BufferedTaskStream, I2SStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and BufferedStream.
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineprotectedvirtualinherited |
|
inlineprotectedinherited |
|
inlinevirtualinherited |
|
inlineoverridevirtual |
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 >.
|
inlineoverridevirtual |
Updates the audio info and calls the callback.
Reimplemented from AudioStream.
defines the callback to receive the actual audio info
|
inline |
optioinally define available bytes for next read
|
inline |
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlinevirtualinherited |
Defines/Changes the output target and registers for audio change notifications.
Reimplemented in TimedStream, VolumeMeter, AudioInputMonitor, QualityAnalysisStream, ReformatBaseStream, FormatConverterStream, and EncodedAudioStream.
|
inlineoverridevirtual |
Defines/Changes the output target.
Implements ModifyingStream.
|
inline |
same as setStream
|
inline |
Instead of reading from the input stream we call this method.
|
inlinevirtualinherited |
Defines/Changes the input & output and registers for audio change notifications.
Reimplemented in VolumeMeter, AudioInputMonitor, QualityAnalysisStream, FormatConverterStream, ReformatBaseStream, TimedStream, and EncodedAudioStream.
|
inline |
same as set Output
|
inlineoverridevirtual |
Defines/Changes the input & output.
Implements ModifyingStream.
|
inline |
After Reading or before writing we call this method to allow to modify the data.
|
inlineinherited |
|
inline |
Instead of writing to the output stream we call this method.
|
inlineoverridevirtual |
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |