blob: ca83c693bfe76dd3a3034b2acf7e235e688f3881 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#ifndef _XAS_SYNTH_H
#define _XAS_SYNTH_H
#include <stdint.h>
#include <sys/types.h>
#include <xas/object.h>
#include <xas/audio.h>
#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 */
|