AdaptiveGain class final
Slow automatic gain control that amplifies quiet capture and never attenuates loud capture.
Built for the models sitting downstream of a microphone, not for listeners. Capture levels vary by an order of magnitude across devices and users — real recordings peaking at 0.05 are ordinary — and a speech-probability model trained on normalized audio simply collapses on input that quiet. Scaling toward a target peak restores the range those models expect.
The running peak decays slowly instead of resetting per chunk, which is what keeps the noise floor from being pumped up between utterances: silence following speech is still measured against the speech that preceded it. Loud input is passed through untouched, so this is never a limiter.
Constructors
- AdaptiveGain({double targetPeak = 0.3, double maxGain = 30, double decay = 0.995})
- Creates a gain stage.
Properties
- decay → double
-
Running-peak decay applied once per apply call.
final
- gain → double
-
Gain the most recent apply used, or 1 when the chunk passed through
untouched.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxGain → double
-
Ceiling on the applied gain, about 30 dB at the default.
final
- runningPeak → double
-
Current running peak, for diagnostics.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetPeak → double
-
Amplitude the running peak is scaled toward.
final
Methods
-
apply(
Float32List chunk) → Float32List -
Folds
chunk's peak into the running peak and returns the scaled chunk. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Forgets the running peak, so the next chunk is measured on its own.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- deadband → const double
- Gain below which a chunk is passed through unchanged.
- silenceFloor → const double
- Running peak below which the input counts as silence.