mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
util/spkmodem-decode: separate silence check
i conflated two separate tests in a previous change. the silence check was defeated by still checking f alongside it, which would be set, thus satisfying the condition, and proceeding, which defeats the purpose of the silence check (ignore false signal that is actually noise) - so in the original patch that i wrote, the extra checks actually do nothing. this patch fixes that, and makes the logic a bit clearer. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -460,25 +460,30 @@ auto_detect_tone(struct decoder_state *st)
|
|||||||
{
|
{
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
/*
|
|
||||||
* Don't also run auto-detect during decode,
|
|
||||||
* otherwise it would run for every sample.
|
|
||||||
*/
|
|
||||||
if (st->learn_samples >= LEARN_SAMPLES)
|
if (st->learn_samples >= LEARN_SAMPLES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check both FIR windows.
|
* Ignore silence / near silence.
|
||||||
* Inside separator frames, the separator window contains tone,
|
* Both FIR windows will be near zero when no signal exists.
|
||||||
* during data frames the data window does; a minimum of
|
*/
|
||||||
* the two captures the lowest active tone cluster more reliably.
|
if (st->freq_data <= 2 && st->freq_separator <= 2) {
|
||||||
|
st->learn_samples++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Choose the lowest active tone.
|
||||||
|
* Separator frames carry tone in the separator window,
|
||||||
|
* data frames carry tone in the data window.
|
||||||
*/
|
*/
|
||||||
f = st->freq_data;
|
f = st->freq_data;
|
||||||
if (st->freq_separator > 0 && st->freq_separator < f)
|
|
||||||
|
if (f <= 0 || (st->freq_separator > 0 &&
|
||||||
|
st->freq_separator < f))
|
||||||
f = st->freq_separator;
|
f = st->freq_separator;
|
||||||
if (f > 0 || /* prevent noise from corrupting tone-learning */
|
|
||||||
st->freq_data > 2 || /* <--- stop from */
|
if (f > 0) {
|
||||||
st->freq_separator > 2) { /* learning silence if no signal */
|
|
||||||
if (f < st->freq_min)
|
if (f < st->freq_min)
|
||||||
st->freq_min = f;
|
st->freq_min = f;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user