#include #include xas_synth *xas_synth_new(size_t sample_rate, xas_synth_callback_sample sample, xas_synth_callback_destroy destroy, void *ctx) { xas_synth *synth; if ((synth = malloc(sizeof(*synth))) == NULL) { goto error_malloc_synth; } synth->sample_rate = sample_rate; synth->sample = sample; synth->destroy = destroy; synth->ctx = ctx; return synth; error_malloc_synth: return NULL; } void xas_synth_destroy(xas_synth *synth) { if (synth->destroy) { synth->destroy(synth, synth->ctx); } } int16_t xas_synth_sample(xas_synth *synth) { return synth->sample(synth, synth->ctx); } ssize_t xas_synth_fill(xas_synth *synth, int16_t *samples, size_t count) { size_t i; for (i=0; isample(synth, synth->ctx); } return count; }