Skip to content

Commit

Permalink
gh-30: Implements wasm bindings for all of libsignaletic.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Jul 17, 2024
1 parent 2c918ad commit f9ae2d9
Show file tree
Hide file tree
Showing 4 changed files with 2,263 additions and 194 deletions.
19 changes: 8 additions & 11 deletions libsignaletic/include/libsignaletic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1041,16 +1041,16 @@ float sig_DelayLine_allpassReadAtTime(struct sig_DelayLine* self,
float source, float tapTime, float sampleRate, float previousSample);

float sig_DelayLine_readAtTimes(struct sig_DelayLine* self, float source,
float* tapTimes, float* tapGains, size_t numTaps,
float_array_ptr tapTimes, float_array_ptr tapGains, size_t numTaps,
float sampleRate, float timeScale);

float sig_DelayLine_linearReadAtTimes(struct sig_DelayLine* self,
float source, float* tapTimes, float* tapGains, size_t numTaps,
float sampleRate, float timeScale);
float source, float_array_ptr tapTimes, float_array_ptr tapGains,
size_t numTaps, float sampleRate, float timeScale);

float sig_DelayLine_cubicReadAtTimes(struct sig_DelayLine* self,
float source, float* tapTimes, float* tapGains, size_t numTaps,
float sampleRate, float timeScale);
float source, float_array_ptr tapTimes, float_array_ptr tapGains,
size_t numTaps, float sampleRate, float timeScale);

void sig_DelayLine_write(struct sig_DelayLine* self, float sample);

Expand Down Expand Up @@ -1817,12 +1817,9 @@ struct sig_dsp_DustGate {

struct sig_dsp_DustGate* sig_dsp_DustGate_new(struct sig_Allocator* allocator,
struct sig_SignalContext* context);

void sig_dsp_DustGate_init(struct sig_dsp_DustGate* self,
struct sig_SignalContext* context);

void sig_dsp_DustGate_generate(void* signal);

void sig_dsp_DustGate_destroy(struct sig_Allocator* allocator,
struct sig_dsp_DustGate* self);

Expand Down Expand Up @@ -1981,6 +1978,8 @@ struct sig_dsp_List* sig_dsp_List_new(
struct sig_Allocator* allocator, struct sig_SignalContext* context);
void sig_dsp_List_init(struct sig_dsp_List* self,
struct sig_SignalContext* context);
float sig_dsp_List_constrain(bool shouldWrap, float index,
float lastIndex, float listLength);
void sig_dsp_List_generate(void* signal);
void sig_dsp_List_destroy(struct sig_Allocator* allocator,
struct sig_dsp_List* self);
Expand Down Expand Up @@ -2008,8 +2007,6 @@ struct sig_dsp_LinearMap* sig_dsp_LinearMap_new(
struct sig_Allocator* allocator, struct sig_SignalContext* context);
void sig_dsp_LinearMap_init(struct sig_dsp_LinearMap* self,
struct sig_SignalContext* context);
float sig_dsp_List_constrain(bool shouldWrap, float index,
float lastIndex, float listLength);
void sig_dsp_LinearMap_generate(void* signal);
void sig_dsp_LinearMap_destroy(struct sig_Allocator* allocator,
struct sig_dsp_LinearMap* self);
Expand Down Expand Up @@ -2419,7 +2416,7 @@ struct sig_dsp_Calibrator_Node {
};

void sig_dsp_Calibrator_Node_init(struct sig_dsp_Calibrator_Node* nodes,
float* targetValues, size_t numNodes);
float_array_ptr targetValues, size_t numNodes);

size_t sig_dsp_Calibrator_locateIntervalForValue(float x,
struct sig_dsp_Calibrator_Node* nodes, size_t numNodes);
Expand Down
16 changes: 8 additions & 8 deletions libsignaletic/src/libsignaletic.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,22 +847,22 @@ inline float sig_DelayLine_allpassReadAtTime(struct sig_DelayLine* self,
return tapSum

inline float sig_DelayLine_readAtTimes(struct sig_DelayLine* self,
float source, float* tapTimes, float* tapGains, size_t numTaps,
float sampleRate, float timeScale) {
float source, float_array_ptr tapTimes, float_array_ptr tapGains,
size_t numTaps, float sampleRate, float timeScale) {
sig_DelayLine_readAtTimes_IMPL(self, source, tapTimes,
tapGains, numTaps, sampleRate, timeScale, sig_DelayLine_readAt);
}

inline float sig_DelayLine_linearReadAtTimes(struct sig_DelayLine* self,
float source, float* tapTimes, float* tapGains, size_t numTaps,
float sampleRate, float timeScale) {
float source, float_array_ptr tapTimes, float_array_ptr tapGains,
size_t numTaps, float sampleRate, float timeScale) {
sig_DelayLine_readAtTimes_IMPL(self, source, tapTimes,
tapGains, numTaps, sampleRate, timeScale, sig_DelayLine_linearReadAt);
}

inline float sig_DelayLine_cubicReadAtTimes(struct sig_DelayLine* self,
float source, float* tapTimes, float* tapGains, size_t numTaps,
float sampleRate, float timeScale) {
float source, float_array_ptr tapTimes, float_array_ptr tapGains,
size_t numTaps, float sampleRate, float timeScale) {
sig_DelayLine_readAtTimes_IMPL(self, source, tapTimes,
tapGains,numTaps, sampleRate, timeScale, sig_DelayLine_cubicReadAt);
}
Expand Down Expand Up @@ -3553,10 +3553,10 @@ struct sig_dsp_Calibrator* sig_dsp_Calibrator_new(

inline void sig_dsp_Calibrator_Node_init(
struct sig_dsp_Calibrator_Node* nodes,
float* targetValues, size_t numNodes) {
float_array_ptr targetValues, size_t numNodes) {
for (size_t i = 0; i < numNodes; i++) {
struct sig_dsp_Calibrator_Node* node = &nodes[i];
node->target = node->avg = targetValues[i];
node->target = node->avg = FLOAT_ARRAY(targetValues)[i];
node->numSamplesRecorded = 0;
node->min = INFINITY;
node->max = -INFINITY;
Expand Down
Loading

0 comments on commit f9ae2d9

Please sign in to comment.