Experimental (do not merge) - gain tuning for mWW microhone #410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an experimental firmware for testing purposes only, do not merge!
The audio fed into microWakeWord does not use the XMOS's Automatic Gain Control (AGC) algorithm as it interferes with mWW's own autogain. mWW's autogain works only on short timescales, but it does seem beneficial for wake word accuracy to increase the gain of the incoming audio on longer timescales.
This experimental firmware attempts to find the noise floor of the room by comparing the peak and RMS sound levels. If they are close enough, then we assume the RMS value is the noise floor. This PR attempts to tune the gain factor, in the long term, so that the RMS value matches the target RMS level. This is meant to be a slow tuning effect, so it won't rapidly change or even change at all while there are loud noises in the room. It should settle near the target RMS level once the sound levels are stable for long periods of time. Note that it will log gain factor adjustments in case you are monitoring them.
This exposes 4 new entities in Home Assistant: a switch enabling or disabling the new algorithm, a number entity allowing you to configure the target RMS level, and two sensors reporting the peak and RMS sound levels for the mWW audio.
For anyone testing this firmware, we are interested in the following questions (though other observations are also encouraged!):