blob: 53f3343b139c27f8d42f1d500ef03f7e1d12b794 (
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
|
#ifndef _XAS_SYNTH_H
#define _XAS_SYNTH_H
#include <stdint.h>
#include <sys/types.h>
#include <xas/audio.h>
#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 {
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;
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_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 */
|