|
arduino-audio-tools
|
Stream support for A2DP using https://github.com/pschatzmann/ESP32-A2DP: begin(TX_MODE) opens a a2dp_source and begin(RX_MODE) a a2dp_sink. The data is in int16_t with 2 channels at 44100 hertz. We support only one instance of the class! Please note that this is a conveniance class that supports the stream api, however this is rather inefficient, beause quite a big buffer needs to be allocated. It is recommended to use the API with the callbacks. Examples can be found in the a2dp examples directory starting with basic. More...
#include <A2DPStream.h>
Public Member Functions | |
| A2DPStream () | |
| ~A2DPStream () | |
| Release the allocate a2dp_source or a2dp_sink. | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual void | addNotifyAudioChange (AudioInfoSupport &bi) |
| Adds target to be notified about audio changes. | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfo () override |
| provides the actual input AudioInfo | |
| virtual AudioInfo | audioInfoOut () |
| virtual AudioInfo | audioInfoOut () |
| int | available () override |
| Provides the number of bytes available to read. | |
| int | availableForWrite () override |
| Provides the number of bytes available to write. | |
| bool | begin (A2DPConfig cfg) |
| Starts the processing. | |
| bool | begin (RxTxMode mode, const char *name, bool wait_for_connection=true) |
| Starts the processing. | |
| virtual bool | begin () |
| BaseBuffer< uint8_t > & | buffer () |
| Provides access to the buffer. | |
| void | clear () |
| Clears the buffer. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| A2DPConfig | defaultConfig (RxTxMode mode=RX_MODE) |
| void | end () override |
| virtual void | flush () override |
| virtual void | flush () override |
| bool | isConnected () |
| checks if we are connected | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| bool | isReady () |
| is ready to process data | |
| operator bool () | |
| convert to bool | |
| size_t | readBytes (uint8_t *data, size_t len) override |
| Reads the data from the temporary buffer. | |
| virtual size_t | readSilence (uint8_t *buffer, size_t length) |
| Source to generate silence: just sets the buffer to 0. | |
| 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 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. | |
| virtual void | setAudioInfo (AudioInfo newInfo) override |
| Defines the input AudioInfo. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active). | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active). | |
| void | setSilenceOnNoData (bool silence) |
| Manage config.silence_on_nodata dynamically. | |
| bool | setVolume (float volume) override |
| Define the volume (values between 0.0 and 1.0). | |
| void | setWriteBufferSize (int size) |
| void | setWriteBufferSize (int size) |
| BluetoothA2DPSink & | sink () |
| provides access to the BluetoothA2DPSink | |
| BluetoothA2DPSource & | source () |
| provides access to the BluetoothA2DPSource | |
| virtual float | volume () |
| provides the actual volume in the range of 0.0f to 1.0f | |
| virtual float | volume () |
| provides the actual volume in the range of 0.0f to 1.0f | |
| size_t | write (const uint8_t *data, size_t len) override |
| Writes the data into a temporary send buffer - where it can be picked up by the callback. | |
| virtual size_t | write (uint8_t ch) override |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
| virtual void | writeSilence (size_t len) |
| Writes len bytes of silence (=0). | |
Protected Member Functions | |
| virtual int | not_supported (int out, const char *msg="") |
| virtual int | not_supported (int out, const char *msg="") |
| void | notify_base_Info (int rate) |
| notify subscriber with AudioInfo | |
| void | notifyAudioChange (AudioInfo info) |
| void | notifyAudioChange (AudioInfo info) |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read(). | |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read(). | |
Static Protected Member Functions | |
| static void | a2dp_state_callback (esp_a2d_connection_state_t state, void *caller) |
| static void | a2dp_stream_sink_sound_data (const uint8_t *data, uint32_t len) |
| callback used by A2DP to write the sound data | |
| static int32_t | a2dp_stream_source_sound_data (uint8_t *data, int32_t len) |
| static bool | detected_device (const char *ssid, esp_bd_addr_t address, int rssi) |
| static void | sample_rate_callback (uint16_t rate) |
| callback to update audio info with used a2dp sample rate | |
Protected Attributes | |
| int | _timeout = 10 |
| BluetoothA2DPCommon * | a2dp =nullptr |
| const int | A2DP_MAX_VOL = 128 |
| BluetoothA2DPSink * | a2dp_sink = nullptr |
| BluetoothA2DPSource * | a2dp_source = nullptr |
| A2DPConfig | config |
| AudioInfo | info |
| bool | is_notify_active = true |
| Vector< AudioInfoSupport * > | notify_vector |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| float | volume_value = 1.0f |
| int | write_buffer_size = 8 |
Stream support for A2DP using https://github.com/pschatzmann/ESP32-A2DP: begin(TX_MODE) opens a a2dp_source and begin(RX_MODE) a a2dp_sink. The data is in int16_t with 2 channels at 44100 hertz. We support only one instance of the class! Please note that this is a conveniance class that supports the stream api, however this is rather inefficient, beause quite a big buffer needs to be allocated. It is recommended to use the API with the callbacks. Examples can be found in the a2dp examples directory starting with basic.
|
inline |
|
inline |
Release the allocate a2dp_source or a2dp_sink.
|
inlinestaticprotected |
|
inlinestaticprotected |
callback used by A2DP to write the sound data
|
inlinestaticprotected |
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.
|
inlinevirtualinherited |
Adds target to be notified about audio changes.
Reimplemented in CodecNOP, CodecNOP, EncodedAudioOutput, and EncodedAudioStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AdapterAudioOutputToAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, TimerCallbackAudioStream, TimerCallbackAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, InputMerge< T >, JupyterAudioT< T >, JupyterAudioT< int16_t >, MozziStream, PureDataStream, and TimerCallbackAudioStream.
|
inlineoverridevirtualinherited |
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AdapterAudioOutputToAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, TimerCallbackAudioStream, TimerCallbackAudioStream, EncodedAudioStream, GeneratedSoundStream< T >, InputMerge< T >, JupyterAudioT< T >, JupyterAudioT< int16_t >, MozziStream, PureDataStream, and TimerCallbackAudioStream.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, FormatConverterStream, MP3EncoderShine, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, PureDataStream, PWMAudioOutput< PWMDriverT >, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlinevirtualinherited |
provides the actual output AudioInfo: this is usually the same as audioInfo() unless we use a transforming stream
Reimplemented in ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, FormatConverterStream, MP3EncoderShine, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, PureDataStream, PWMAudioOutput< PWMDriverT >, ResampleStream, ResampleStreamT< TInterpolator >, and SupportedRatesStream.
|
inlineoverridevirtual |
Provides the number of bytes available to read.
Reimplemented from BaseStream.
|
inlineoverridevirtual |
Provides the number of bytes available to write.
Reimplemented from BaseStream.
|
inline |
Starts the processing.
|
inline |
Starts the processing.
|
inlinevirtualinherited |
Reimplemented in AdapterAudioOutputToAudioStream, AdaptiveResamplingStream, AnalogAudioStream, AdapterAudioOutputToAudioStream, AudioInputMonitor, AudioInputMonitor, AudioStreamWrapper, AudioStreamWrapper, AudioTimeSourceStream, CallbackStream, CallbackStream, CatStream, CatStream, DynamicMemoryStream, DynamicMemoryStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMerge< T >, InputMerge< T >, MemoryStream, MemoryStream, ProgressStream, ProgressStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, Throttle, Throttle, TimedStream, TimerCallbackAudioStream, TimerCallbackAudioStream, VolumeMeter, VolumeMeter, AudioBoardStream, AudioEffectStream, AudioEffectStreamT< T >, AudioFFTBase, AudioInputMonitor, AudioKitStream, AudioLoRa, AudioMP34DT05, AudioOutputWithCallback, AudioStreamWrapper, AudioTimeSourceStream, AutomaticGainControlStream, CallbackStream, CatStream, ChannelFormatConverterStream, ChannelFormatConverterStreamT< T >, DynamicMemoryStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, ESPNowStream, FileLoopT< FileType >, FileLoopT< File >, FilteredStream< T, TF >, FormatConverterStream, FrequencyDetectorAutoCorrelation, GeneratedSoundStream< T >, GoertzelStream, HLSStreamT< URLStream >, HLSStreamT< URLStreamESP32 >, I2SCodecStream, I2SStream, InputMerge< T >, MeasuringStream, MemoryStream, MiniAudioStream, MozziStream, NRF24Stream, NumberFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, Pipeline, Pipeline::ModifyingStreamAdapter, PortAudioStream, ProgressStream, PureDataStream, QualityAnalysisStream, QueueStream< T >, ResampleStream, ResampleStreamT< TInterpolator >, SPDIFOutput, StdioStream, SupportedRatesStream, Throttle, TimedStream, TimerCallbackAudioStream, USBAudioDeviceBase, USBAudioHostBase, VBANStream, VolumeMeter, VolumeStream, VS1053Stream, and WM8960Stream.
|
inline |
Provides access to the buffer.
|
inline |
Clears the buffer.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >, RTSPClient< EthernetClient, EthernetUDP >, and RTSPClient< WiFiClient, WiFiUDP >.
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >, RTSPClient< EthernetClient, EthernetUDP >, and RTSPClient< WiFiClient, WiFiUDP >.
|
inline |
|
inlinestaticprotected |
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in AudioStreamWrapper, AudioStreamWrapper, BufferedStream, BufferedStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, TimedStream, AudioEffectStream, AudioEffectStreamT< T >, AudioStreamWrapper, AutomaticGainControlStream, BufferedStream, BufferedTaskStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, FadeStream, FilteredStream< T, TF >, GeneratedSoundStream< T >, I2SStream, MeasuringStream, MemoryStream, Pipeline::ModifyingStreamAdapter, PureDataStream, QualityAnalysisStream, QueueStream< T >, ReformatBaseStream, ResampleStream, RingBufferStream, SupportedRatesStream, TimedStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, and VolumeStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in AudioStreamWrapper, AudioStreamWrapper, BufferedStream, BufferedStream, EncodedAudioStream, FilteredStream< T, TF >, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, MemoryStream, MemoryStream, QueueStream< T >, QueueStream< T >, QueueStream< uint8_t >, ReformatBaseStream, RingBufferStream, RingBufferStream, TimedStream, AudioEffectStream, AudioEffectStreamT< T >, AudioStreamWrapper, AutomaticGainControlStream, BufferedStream, BufferedTaskStream, EncodedAudioStream, Equalizer3BandsPerChannelT< T >, Equalizer3BandsPerChannelT< float >, Equalizer3BandsT< T >, Equalizer3BandsT< float >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, FadeStream, FilteredStream< T, TF >, GeneratedSoundStream< T >, I2SStream, MeasuringStream, MemoryStream, Pipeline::ModifyingStreamAdapter, PureDataStream, QualityAnalysisStream, QueueStream< T >, ReformatBaseStream, ResampleStream, RingBufferStream, SupportedRatesStream, TimedStream, URLStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, URLStreamBufferedT< ICYStreamESP32 >, URLStreamBufferedT< URLStream >, URLStreamBufferedT< URLStreamESP32 >, and VolumeStream.
|
inline |
checks if we are connected
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inlineinherited |
Checks if the automatic AudioInfo update is active.
|
inline |
is ready to process data
|
inlineprotectedvirtualinherited |
|
inlineprotectedvirtualinherited |
|
inlineprotected |
notify subscriber with AudioInfo
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
inlinevirtual |
convert to bool
Reimplemented from AudioStream.
|
inlineoverridevirtual |
Reads the data from the temporary buffer.
Reimplemented from AudioStream.
|
inlinevirtualinherited |
Source to generate silence: just sets the buffer to 0.
|
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().
|
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.
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
|
inlinestaticprotected |
callback to update audio info with used a2dp sample rate
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AudioInputMonitor, AudioInputMonitor, CallbackStream, CallbackStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, ProgressStream, ProgressStream, TimedStream, TimerCallbackAudioStream, TimerCallbackAudioStream, VolumeMeter, and VolumeMeter.
|
inlineoverridevirtualinherited |
Defines the input AudioInfo.
Implements AudioInfoSupport.
Reimplemented in AdapterAudioOutputToAudioStream, AudioInputMonitor, AudioInputMonitor, CallbackStream, CallbackStream, EncodedAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, ProgressStream, ProgressStream, TimedStream, TimerCallbackAudioStream, TimerCallbackAudioStream, VolumeMeter, and VolumeMeter.
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active).
|
inlineinherited |
Deactivate/Reactivate automatic AudioInfo updates: (default is active).
|
inline |
Manage config.silence_on_nodata dynamically.
|
inlineoverridevirtual |
Define the volume (values between 0.0 and 1.0).
Reimplemented from VolumeSupport.
|
inlineinherited |
|
inlineinherited |
|
inline |
provides access to the BluetoothA2DPSink
|
inline |
provides access to the BluetoothA2DPSource
|
inlinevirtualinherited |
provides the actual volume in the range of 0.0f to 1.0f
Reimplemented in AudioPlayer, I2SCodecStream, USBAudioStreamBase, VolumeStream, and VS1053Stream.
|
inlinevirtualinherited |
provides the actual volume in the range of 0.0f to 1.0f
Reimplemented in AudioPlayer, I2SCodecStream, USBAudioStreamBase, VolumeStream, and VS1053Stream.
|
inlineoverridevirtual |
Writes the data into a temporary send buffer - where it can be picked up by the callback.
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
inlinevirtualinherited |
Writes len bytes of silence (=0).
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |