-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
A very needed feature is an ability to use latency estimation algorithm programmatically outside of signal-estimator CLI and GUI.
In addition to CLI (src/cli
) and GUI (src/gui
), we could add a C library (src/lib
) that works on top of the same low-level C++ classes (src/base
), same as CLI and GUI does.
(Note: C API is preferred over C++ API: it provides better ABI compatibility over library upgrades and across different compilers; it provides compatibility with more languages, since many languages allow to create bindings for C libraries quite easily)
The library does not need to work with ALSA devices. Instead, it should have a simpler interface:
- user creates estimator
- user obtains from it samples for playback
- user passes to it captured samples
- user reads estimated latency from estimator
Something like this:
typedef struct estimator_config {
/* various configuration options: mode, sample rate, channel count, etc */
} estimator_config;
typedef struct estimator_report {
/* reported latency, loss ration, etc */
} estimator_report;
/* opaque handle */
typedef struct estimator estimator;
estimator* estimator_open(const estimator_config* config);
void estimator_pop_output(estimator* estimator, float* samples, size_t num_samples);
void estimator_push_input(estimator* estimator, const float* samples, size_t num_samples);
void estimator_get_report(estimator* estimator, estimator_report* report);
void estimator_close(estimator* estimator);
To implement it, we'll need to use existing IEstimator implementation (depending on selected mode) with custom IReporter implementation that will store results in memory instead of printing them to console.
Important: this API should be thread-safe. It should be allowed to invoke all functions from different threads concurrently.