|
arduino-audio-tools
|
Monitors audio input and reports if the volume exceeds a specified limit within a given period. More...
#include <AudioStreams.h>
Public Member Functions | |
| AudioInputMonitor (AudioOutput &ao, uint8_t limitPercent=20) | |
| Construct a new AudioInputMonitor with an output. | |
| AudioInputMonitor (AudioStream &as, uint8_t limitPercent=20) | |
| Construct a new AudioInputMonitor with an input stream. | |
| AudioInputMonitor (Print &print, uint8_t limitPercent=20) | |
| Construct a new AudioInputMonitor with a Print output. | |
| AudioInputMonitor (Stream &stream, uint8_t limitPercent=20) | |
| Construct a new AudioInputMonitor with a Stream input. | |
| AudioInputMonitor (uint8_t limitPercent=20) | |
| Construct a new AudioInputMonitor with a volume limit in percent. | |
| 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 () |
| virtual int | available () override |
| virtual int | availableForWrite () override |
| bool | begin () override |
| Begin processing with the current audio information. | |
| bool | begin (AudioInfo info) |
| Begin processing with the given audio information. | |
| virtual void | clearNotifyAudioChange () |
| Deletes all change notify subscriptions. | |
| virtual void | end () |
| virtual void | flush () override |
| VolumeMeter & | getVolumeMeter () |
| Access the underlying VolumeMeter. | |
| bool | isActive (uint16_t time_ms=1000) |
| Returns true if the volume exceeded the limit during the last period. | |
| bool | isNotifyActive () |
| Checks if the automatic AudioInfo update is active. | |
| uint8_t | limitPercent () const |
| Get the current volume threshold as percent. | |
| virtual | operator bool () |
| size_t | readBytes (uint8_t *data, size_t len) override |
| Read audio data from the monitor (same as VolumeMeter) | |
| 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 |
| Set the audio information. | |
| void | setLimitPercent (uint8_t percent) |
| Set the volume threshold as percent. | |
| void | setNotifyActive (bool flag) |
| Deactivate/Reactivate automatic AudioInfo updates: (default is active) | |
| void | setOutput (AudioOutput &out) |
| Set the output target. | |
| void | setOutput (Print &out) override |
| Set the output target. | |
| void | setStream (AudioStream &io) |
| Set the input stream. | |
| void | setStream (Stream &io) override |
| Set the input stream. | |
| void | setWriteBufferSize (int size) |
| size_t | write (const uint8_t *data, size_t len) override |
| Write audio data to the monitor (same as VolumeMeter) | |
| 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 |
| AudioInfo | info |
| bool | is_notify_active = true |
| uint8_t | limit_percent = 20 |
| Threshold percent. | |
| Vector< AudioInfoSupport * > | notify_vector |
| uint64_t | time_over_last_volume_limit = 0 |
| Last over-limit time (ms) | |
| RingBuffer< uint8_t > | tmp_in {0} |
| RingBuffer< uint8_t > | tmp_out {0} |
| VolumeMeter | volume_meter |
| Volume calculation. | |
| int | write_buffer_size = MAX_SINGLE_CHARS |
Monitors audio input and reports if the volume exceeds a specified limit within a given period.
This class uses a VolumeMeter internally and tracks if the input volume has exceeded the specified limit during the last period. It can be used in an audio processing chain as a ModifyingStream.
|
inline |
Construct a new AudioInputMonitor with a volume limit in percent.
| limitPercent | The volume threshold as percent (default: 20) |
|
inline |
Construct a new AudioInputMonitor with an input stream.
| as | Reference to an AudioStream |
| limitPercent | The volume threshold as percent (default: 20) |
|
inline |
Construct a new AudioInputMonitor with an output.
| ao | Reference to an AudioOutput |
| limitPercent | The volume threshold as percent (default: 20) |
|
inline |
Construct a new AudioInputMonitor with a Print output.
| Reference to a Print object | |
| limitPercent | The volume threshold as percent (default: 20) |
|
inline |
Construct a new AudioInputMonitor with a Stream input.
| stream | Reference to a Stream object |
| limitPercent | The volume threshold as percent (default: 20) |
|
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 PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
Reimplemented from Stream.
Reimplemented in AudioKitStream, AudioLoRa, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, VBANStream, AudioStreamWrapper, LoRaStream, FaustStream< DSP >, AudioFFTBase, AudioMP34DT05, I2SCodecStream, MiniAudioStream, StdioStream, TfLiteAudioStream, A2DPStream, ESPNowStream, HammingFEC< bytecount, block_t >, HLSStreamT< URLStream >, HttpRequest, ICYStreamT< T >, URLStream, BufferedTaskStream, ReedSolomonFEC< bytecount, additional_bytes >, SPIAudioSlave, UDPStream, AnalogAudioArduino, AnalogAudioStream, AudioEffectStreamT< T >, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, ReformatBaseStream, TimedStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, ConverterStream< T >, MeasuringStream, ProgressStream, Throttle, InputMerge< T >, CallbackStream, FilteredStream< T, TF >, FilteredStream< int16_t, int16_t >, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, CatStream, QueueStream< T >, QueueStream< uint8_t >, DynamicMemoryStream, FadeStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, Pipeline, Pipeline::ModifyingStreamAdapter, VolumeStream, FileLoopT< FileType >, FileLoopT< File >, AudioBLEClient, AudioBLEClient, AudioBLEServer, and AudioBLEServer.
Reimplemented from Print.
Reimplemented in AudioLoRa, UDPStream, VBANStream, AudioStreamWrapper, ConverterStream< T >, LoRaStream, EncodedAudioStream, FaustStream< DSP >, AudioFFTBase, I2SCodecStream, MiniAudioStream, StdioStream, A2DPStream, ESPNowStream, HammingFEC< bytecount, block_t >, AbstractURLStream, URLStreamESP32, ReedSolomonFEC< bytecount, additional_bytes >, SPIAudioSlave, AnalogAudioArduino, AnalogAudioStream, AudioEffectStreamT< T >, 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, VolumeStream, AudioBLEClient, AudioBLEClient, AudioBLEServer, and AudioBLEServer.
|
inlineoverridevirtual |
Begin processing with the current audio information.
Reimplemented from BaseStream.
Begin processing with the given audio information.
| info | AudioInfo structure |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
Reimplemented in FaustStream< DSP >, AudioMP34DT05, I2SCodecStream, MozziStream, PureDataStream, SPDIFOutput, VS1053Stream, WM8960Stream, AdaptiveResamplingStream, AudioLoRa, ESPNowStream, BufferedTaskStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, 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, SPIAudioSlave, AnalogAudioArduino, 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.
|
inline |
Access the underlying VolumeMeter.
Returns true if the volume exceeded the limit during the last period.
| time_ms | The period in milliseconds to check (default: 1000) |
|
inline |
Get the current volume threshold as percent.
Read audio data from the monitor (same as VolumeMeter)
| data | Pointer to buffer to fill |
| len | Number of bytes to read |
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 >.
Set the volume threshold as percent.
| percent | The new volume threshold (0-100) |
Deactivate/Reactivate automatic AudioInfo updates: (default is active)
|
inline |
Set the output target.
| out | Reference to a Print object |
|
inline |
Set the input stream.
| io | Reference to a Stream object |
Write audio data to the monitor (same as VolumeMeter)
| data | Pointer to audio data |
| len | Number of bytes |
Reimplemented from AudioStream.
Reimplemented in MemoryStream, AudioStreamWrapper, BufferedTaskStream, RingBufferStream, BufferedStream, and URLStream.
|
protectedinherited |
|
protectedinherited |
|
protected |
Threshold percent.
|
protectedinherited |
|
protected |
Last over-limit time (ms)
|
protectedinherited |
|
protectedinherited |
|
protected |
Volume calculation.
|
protectedinherited |