#ifndef _XAS_SYNTH_H #define _XAS_SYNTH_H #include #include #include #include #define XAS_SYNTH_DEFAULT_GAIN 1.0f #define XAS_SYNTH_DEFAULT_FREQUENCY 2600 /* Hz */ enum xas_synth_type { XAS_SYNTH_SINE, XAS_SYNTH_SQUARE, XAS_SYNTH_TRIANGLE, XAS_SYNTH_SAWTOOTH }; 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 { xas_object obj; enum xas_synth_type type; enum xas_synth_state state; xas_audio_format format; size_t buffer_size; xas_synth_sample_callback sample; float phase, gain; size_t frequency; }; 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_gain(xas_synth *synth, float gain); void xas_synth_set_frequency(xas_synth *synth, size_t frequency); void xas_synth_set_type(xas_synth *synth, enum xas_synth_type type); void xas_synth_start(xas_synth *synth); void xas_synth_stop(xas_synth *synth); xas_audio_stream *xas_synth_stream_new(xas_synth *synth); #endif /* _XAS_SYNTH_H */