|
arduino-audio-tools
|
Analyzes audio stream quality by detecting clicks/pops, gaps/dropouts, and clipping/corruption. More...
#include <QualityAnalysisStream.h>
Public Member Functions | |
| QualityAnalysisStream ()=default | |
| QualityAnalysisStream (Print &print) | |
| QualityAnalysisStream (Stream &stream) | |
| 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 |
| int | availableForWrite () override |
| bool | begin () override |
| bool | begin (AudioInfo info) |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| void | clearStats () |
| Reset all statistics and detection state. | |
| virtual 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) 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 |
| Defines the input AudioInfo. | |
| void | setCallback (QualityCallback cb) |
| Register a callback for quality issue notifications. | |
| void | setClickThreshold (float ratio) |
| Sample-to-sample jump threshold as ratio of max value (0.0 to 1.0) | |
| void | setClippingMargin (float ratio) |
| Clipping is detected when sample >= max_value * (1 - margin) | |
| void | setClippingMinSamples (int samples) |
| Minimum consecutive samples at max to count as clipping. | |
| void | setDropoutMinSamples (int samples) |
| Minimum consecutive near-silent samples to count as a dropout. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| 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 | setReporting (int period_ms, Print &output) |
| void | setSilenceThreshold (float ratio) |
| Samples below this ratio of max value are considered silent. | |
| void | setStream (AudioStream &io) |
| Defines/Changes the input & output and registers for audio change notifications. | |
| void | setStream (Stream &io) override |
| Defines/Changes the input & output. | |
| void | setWriteBufferSize (int size) |
| const QualityStats & | stats () const |
| Access the accumulated quality statistics. | |
| 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 | |
| void | analyze (const uint8_t *data, size_t len) |
| template<typename T > | |
| void | analyzeT (const uint8_t *buffer, size_t size) |
| virtual int | not_supported (int out, const char *msg="") |
| void | notifyAudioChange (AudioInfo info) |
| void | printReport () |
| void | refillReadBuffer () |
| Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read() | |
| void | reportIfDue () |
| void | resetState () |
Protected Attributes | |
| int | _timeout = 10 |
| QualityCallback | callback = nullptr |
| float | click_threshold = 0.5f |
| float | clipping_margin = 0.01f |
| int | clipping_min_samples = 3 |
| int | consecutive_clipped = 0 |
| int | consecutive_silent = 0 |
| int | dropout_min_samples = 10 |
| bool | has_prev_sample = false |
| bool | in_clipping = false |
| bool | in_dropout = false |
| AudioInfo | info |
| bool | is_notify_active = true |
| uint32_t | last_report_time = 0 |
| float | max_value = 32767.0f |
| Vector< AudioInfoSupport * > | notify_vector |
| Print * | p_out = nullptr |
| Print * | p_report = nullptr |
| Stream * | p_stream = nullptr |
| Vector< float > | prev_sample |
| int | report_period_ms = 0 |
| float | silence_threshold = 0.01f |
| QualityStats | stats_data |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Analyzes audio stream quality by detecting clicks/pops, gaps/dropouts, and clipping/corruption.
Insert this stream into an audio pipeline to monitor signal quality in real time. Data passes through unmodified.
Results are available via stats() or through a callback.
|
default |
|
inline |
|
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.
provides the actual input AudioInfo
Implements AudioInfoSupport.
Reimplemented in JupyterAudioT< T >, MozziStream, TimerCallbackAudioStream, EncodedAudioStream, PureDataStream, AdapterAudioOutputToAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and InputMerge< T >.
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.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
|
inlineoverridevirtual |
Reimplemented from BaseStream.
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inline |
Reset all statistics and detection state.
Reimplemented in FaustStream< DSP >, AudioMP34DT05, I2SCodecStream, MozziStream, PureDataStream, SPDIFOutput, VS1053Stream, WM8960Stream, AdaptiveResamplingStream, AudioLoRa, ESPNowStream, BufferedTaskStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, USBAudioDeviceBase, Equalizer3Bands, I2SStream, AudioStreamWrapper, TimerCallbackAudioStream, FormatConverterStream, GoertzelStream, FileLoopT< FileType >, FileLoopT< File >, EqualizerNBands< SampleT, AccT, NUM_TAPS, NUM_BANDS >, LoRaStream, EncodedAudioStream, AudioFFTBase, AudioKitStream, MiniAudioStream, PortAudioStream, StdioStream, A2DPStream, HLSStreamT< URLStream >, HttpRequest, ICYStreamT< T >, URLStream, URLStreamESP32, NRF24Stream, SPIAudioSlave, AnalogAudioStream, AudioEffectStreamT< T >, Equalizer3BandsPerChannel, ReformatBaseStream, AdapterAudioOutputToAudioStream, MemoryStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMixer< T, SumT >, InputMerge< T >, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStream, NumberFormatConverterStream, CatStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, Pipeline, Pipeline::ModifyingStreamAdapter, VolumeStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, AudioBLEServer, AbstractURLStream, and AudioBLEStream.
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.
|
inlineprotected |
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 >.
|
inlineprotected |
|
inlineprotected |
Defines the input AudioInfo.
Reimplemented from AudioStream.
|
inline |
Register a callback for quality issue notifications.
Sample-to-sample jump threshold as ratio of max value (0.0 to 1.0)
Clipping is detected when sample >= max_value * (1 - margin)
Minimum consecutive samples at max to count as clipping.
Minimum consecutive near-silent samples to count as a dropout.
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inlinevirtual |
Defines/Changes the output target and registers for audio change notifications.
Reimplemented from ModifyingStream.
Defines/Changes the output target.
Implements ModifyingStream.
Enable periodic reporting of quality KPIs
| period_ms | Reporting interval in milliseconds |
| output | Print target (e.g. Serial) |
Samples below this ratio of max value are considered silent.
|
inlinevirtual |
Defines/Changes the input & output and registers for audio change notifications.
Reimplemented from ModifyingStream.
Defines/Changes the input & output.
Implements ModifyingStream.
|
inline |
Access the accumulated quality statistics.
Reimplemented from AudioStream.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |