Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create C API for signal-estimator #33

Open
gavv opened this issue Sep 19, 2023 · 0 comments
Open

Create C API for signal-estimator #33

gavv opened this issue Sep 19, 2023 · 0 comments
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome

Comments

@gavv
Copy link
Owner

gavv commented Sep 19, 2023

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.

@gavv gavv added feature New feature or request help wanted Contributions are welcome good first issue Good for newcomers labels Sep 19, 2023
@gavv gavv pinned this issue Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers help wanted Contributions are welcome
Projects
None yet
Development

No branches or pull requests

1 participant