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 () |
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.
|
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 PureDataStream, PWMAudioOutput, ChannelFormatConverterStreamT< T >, ChannelFormatConverterStream, NumberFormatConverterStreamT< TFrom, TTo >, NumberFormatConverterStream, FormatConverterStream, Pipeline, ResampleStream, and ResampleStreamT< TInterpolator >.
|
inlineoverridevirtualinherited |
Reimplemented from Stream.
Reimplemented in AudioKitStream, AudioFFTBase, I2SCodecStream, TfLiteAudioStream, A2DPStream, HLSStreamT< URLStream >, ICYStreamT< T >, BufferedTaskStream, UDPStream, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, TimedStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, BufferedStream, ConverterStream< T >, InputMerge< T >, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, Pipeline::ModifyingStreamAdapter, and VolumeStream.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in UDPStream, AudioFFTBase, I2SCodecStream, A2DPStream, AbstractURLStream, URLStreamESP32, Equalizer3Bands, Equalizer3BandsPerChannel, I2SStream, MeasuringStream, ProgressStream, FrequencyDetectorAutoCorrelation, FrequencyDetectorZeroCrossing, and VolumeStream.
|
inlineoverridevirtual |
Begin processing with the current audio information.
Reimplemented from BaseStream.
|
inline |
Begin processing with the given audio information.
info | AudioInfo structure |
|
inlinevirtualinherited |
Deletes all change notify subscriptions.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlinevirtualinherited |
Reimplemented in FaustStream< DSP >, I2SCodecStream, VS1053Stream, WM8960Stream, AdaptiveResamplingStream, ESPNowStream, I2SStream, TimerCallbackAudioStream, GoertzelStream, AudioFFTBase, AudioKitStream, HLSStreamT< URLStream >, HttpRequest, ICYStreamT< T >, AnalogAudioStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, InputMixer< T >, InputMerge< T >, QueueStream< T >, QueueStream< uint8_t >, and Pipeline.
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in ResampleStream, BufferedTaskStream, and BufferedStream.
|
inline |
Access the underlying VolumeMeter.
|
inline |
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.
|
inlinevirtualinherited |
Reimplemented in A2DPStream, ICYStreamT< T >, I2SStream, MemoryStream, and Pipeline.
|
inlineoverridevirtual |
Read audio data from the monitor (same as VolumeMeter)
data | Pointer to buffer to fill |
len | Number of bytes to read |
Reimplemented from AudioStream.
|
inlinevirtualinherited |
Removes a target in order not to be notified about audio changes.
Reimplemented in RTSPClient< TcpClient, UdpSocket >.
|
inlineoverridevirtual |
|
inline |
Set the volume threshold as percent.
percent | The new volume threshold (0-100) |
|
inline |
Set the output target.
out | Reference to a Print object |
|
inlineoverridevirtual |
|
inline |
Set the input stream.
io | Reference to a Stream object |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Write audio data to the monitor (same as VolumeMeter)
data | Pointer to audio data |
len | Number of bytes |
Reimplemented from AudioStream.
|
inlineoverridevirtualinherited |
Reimplemented in BufferedTaskStream, and BufferedStream.