SilenceDetector class
Processes the stream of microphone intensity to notify when a silence period begins of ends based on the values received.
The class achieves its purpose by:
- Receiving a continuous stream of decibel levels from the microphone.
- Maintaining a history of recent intensity values to analyze patterns.
- Detecting transitions between silence and non-silence based on the calculated threshold, considering at least 90% of samples as silent to confirm a silent period.
- Signaling via a
StreamController
when silence begins or ends.
Constructors
-
SilenceDetector({required Stream<
double> decibelsStream}) -
decibelsStream
is a stream of microphone intensities changes received every X amount of time. The values are negative, where values closer to zero mean the microphone is picking a loud sound.
Properties
Methods
-
clear(
) → void -
dispose(
) → void -
getMaxSilenceIntensity(
) → double - Calculates the maximum value that is considered silence.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- minimumVariance ↔ double
-
getter/setter pair
- minPercentTolerance ↔ double
-
The minimum percentage of silence a list of values can have as silence
to be considered a period of silence.
This value is rounded up in case of floating point result.
getter/setter pair
- minSilenceCount ↔ int
-
The amount of samples that have a constant amount of silence or loud noise
to begin to conside a "Period of silence" or "Period of loud sounds".
getter/setter pair
- totalSamplesToKeep ↔ int
-
The amount of instances of the microphone to keep in the
_history
list.getter/setter pair