gavv / signal-estimator

Measure characteristics of a looped back signal.
MIT License
67 stars 20 forks source link

Add --min-latency and --max-latency options #40

Open gavv opened 1 year ago

gavv commented 1 year ago

Overview

Implement two new options, --min-latency and --max-latency, that define allowed range for latency measurements.

When min and max are provided, signal-estimator should perform measurement only in time window [T + min; T + max], where T is time of the output impulse.

We should also allow providing only min or only max, for convenience.

These options may be very useful when there are duplicate loopback paths and you need to filter out unwanted ones. For example, when input microphone hears impulse twice, first time when we play it, and second time when it is looped back from measured loopback.

Implementation

This can be implemented quite easily using decorator pattern. We can add a new implementation of IEstimator that wraps another (underlying) IEstimator instance and works as follows:

In other words, the new IEstimator wraps another IEstimator, it passes output frames to it as is, and it zeroizes input frame outside of the allowed range.

With this decorator approach, the logic of min/max latency will work with any IEstimator implementation (i.e. both StepsLatencyEstimator and CorrelationLatencyEstimator).

To make it work, we'll also need to add a flag to Frame indicating whether it contains impulse. We can add has_impulse() and set_has_impulse() methods to Frame, and then we can modify StepsGenerator and ImpulseGenerator to set the flag for frames that have output impulse.

Nystana commented 1 month ago

Hello I'd like to try to solve this issue

gavv commented 1 month ago

@Nystana Thanks!

Nystana commented 2 weeks ago

I'm wortking on this issue and I'd like to ask whether there is a way how can I easily test this, my setup is no Hardware apart from headphones with mic on maybe I can find speakers, and also these new options are part of which option group and what is their type expected to be? @gavv Thank you!

Nystana commented 2 weeks ago

Also how should we go about controbuting I was able to clone this project without forking it, what is the proper way to contribute?

Nystana commented 1 week ago

Could you please explain the behvaior of the steps and impulse generator I'm having difficulties find where to se the flags for the frame