lichen-community-systems / signaletic

A music signal processing library designed for embedded environments and Web Assembly, in C
MIT License
7 stars 2 forks source link

Create Web Assembly bindings for all Signals #30

Open colinbdclark opened 2 years ago

colinbdclark commented 2 years ago

Currently, Web Assembly support is limited to the core functions. The Signals can also be bound, but some research is needed on how to access and use the Emscripten function pointer table from JavaScript.

After that, it should be possible to create bindings that enable all the Signals to be accessed from JavaScript (and thus to run Signaletic in an AudioWorklet).

colinbdclark commented 2 years ago

21 Added bindings for these Signals:

We still need bindings for:

colinbdclark commented 1 month ago

There are a handful of situations I haven't been able to figure out how to create workable Emscripten-compatible WebIDL bindings for:

  1. Pointers to void pointers, either as members of an interface or arguments to a function. For example:
struct sig_List {
    void** items;
    size_t capacity;
    size_t length;
};

void sig_List_init(struct sig_List* self, void** items, size_t capacity);
  1. Functions and function pointer members that take arguments to self (in the C sense of the term), such as:
typedef void (*sig_dsp_SignalEvaluator_evaluate)(
    struct sig_dsp_SignalEvaluator* self);

struct sig_dsp_SignalEvaluator {
    sig_dsp_SignalEvaluator_evaluate evaluate;
};

struct sig_dsp_SignalListEvaluator {
    sig_dsp_SignalEvaluator_evaluate evaluate;
    struct sig_List* signalList;

In these cases, I've chosen to omit members and not create bindings for functions.