diff options
Diffstat (limited to 'src/synth.c')
-rw-r--r-- | src/synth.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/synth.c b/src/synth.c index 96956c5..d27b7a6 100644 --- a/src/synth.c +++ b/src/synth.c @@ -123,6 +123,12 @@ static int synth_stop(xas_synth *synth, ...) { return 0; } +static int set_freq(xas_synth *synth, size_t freq) { + xas_synth_set_frequency(synth, freq); + + return 0; +} + static int set_gain(xas_synth *synth, float gain) { xas_synth_set_gain(synth, gain); @@ -150,6 +156,16 @@ error_invalid_type: return -1; } +static xas_object_call_table call_table = { + .start = (xas_object_start_callback)synth_start, + .stop = (xas_object_stop_callback)synth_stop, + .set_type = (xas_object_set_type_callback)set_type, + .set_freq = (xas_object_set_freq_callback)set_freq, + .set_gain = (xas_object_set_gain_callback)set_gain, + .stream_new = (xas_object_stream_new_callback)xas_synth_stream_new, + .destroy = (xas_object_destroy_callback)xas_synth_destroy +}; + xas_synth *xas_synth_new(xas_audio_format format, size_t buffer_size, enum xas_synth_type type) { @@ -159,11 +175,7 @@ xas_synth *xas_synth_new(xas_audio_format format, goto error_malloc_synth; } - synth->obj.start = (xas_object_start_callback)synth_start; - synth->obj.stop = (xas_object_stop_callback)synth_stop; - synth->obj.set_gain = (xas_object_set_gain_callback)set_gain; - synth->obj.stream_new = (xas_object_stream_new_callback)xas_synth_stream_new; - synth->obj.destroy = (xas_object_destroy_callback)xas_synth_destroy; + synth->obj.table = &call_table; synth->state = XAS_SYNTH_IDLE; synth->phase = 0.0f; |