diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/xas/synth.h | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/include/xas/synth.h b/include/xas/synth.h index 20446cd..53f3343 100644 --- a/include/xas/synth.h +++ b/include/xas/synth.h @@ -6,23 +6,49 @@ #include <xas/audio.h> -typedef struct _xas_synth xas_synth; +#define XAS_SYNTH_DEFAULT_FREQUENCY 2600 /* Hz */ -typedef int16_t (*xas_synth_callback_sample)(xas_synth *synth, void *ctx); +enum xas_synth_type { + XAS_SYNTH_SINE, + XAS_SYNTH_SQUARE, + XAS_SYNTH_TRIANGLE, + XAS_SYNTH_SAWTOOTH +}; -typedef void (*xas_synth_callback_cleanup)(xas_synth *synth, void *ctx); +enum xas_synth_state { + XAS_SYNTH_IDLE, + XAS_SYNTH_ACTIVE +}; + +typedef struct _xas_synth xas_synth; + +typedef int16_t (*xas_synth_sample_callback)(xas_synth *synth); struct _xas_synth { + enum xas_synth_type type; + enum xas_synth_state state; + xas_audio_format format; - xas_synth_callback_sample sample; - xas_synth_callback_cleanup cleanup; - void *ctx; + size_t buffer_size; + + xas_synth_sample_callback sample; + + float phase; + size_t frequency; }; -xas_audio_stream *xas_synth_new(xas_synth_callback_sample sample, - xas_synth_callback_cleanup cleanup, - xas_audio_format format, - size_t buffer_size, - void *ctx); +xas_synth *xas_synth_new(xas_audio_format format, + size_t buffer_size, + enum xas_synth_type type); + +void xas_synth_destroy(xas_synth *synth); + +void xas_synth_set_frequency(xas_synth *synth, size_t frequency); + +void xas_synth_start(xas_synth *synth); + +void xas_synth_stop(xas_synth *synth); + +xas_audio_stream *xas_synth_new_stream(xas_synth *synth); #endif /* _XAS_SYNTH_H */ |