1 #pragma once
2 
3 #include "SDL.h"
4 
5 #define WG_CHAIN_OSCS 4
6 
7 typedef enum
8 {
9 	WG_OSC_SINE,
10 	WG_OSC_SQUARE,
11 	WG_OSC_SAW,
12 	WG_OSC_TRIANGLE,
13 	WG_OSC_NOISE,
14 	WG_NUM_OSCS
15 } WgOscType;
16 
17 typedef enum
18 {
19 	WG_OP_ADD,
20 	WG_OP_MUL,
21 	WG_NUM_OPS
22 } WgOpType;
23 
24 typedef struct
25 {
26 	WgOscType osc;
27 	WgOpType op;
28 	int mult, shift;
29 	int exp;
30 	float exp_c;
31 	Uint32 flags;
32 } WgOsc;
33 
34 enum
35 {
36 	WG_OSC_FLAG_ABS = 1,
37 	WG_OSC_FLAG_NEG = 2
38 };
39 
40 typedef struct
41 {
42 	WgOsc chain[WG_CHAIN_OSCS];
43 	int num_oscs, length;
44 } WgSettings;
45 
46 typedef struct
47 {
48 	const char *name;
49 	WgSettings settings;
50 } WgPreset;
51 
52 void wg_gen_waveform(WgOsc *chain, int num_oscs, Sint16 *data, int len);
53 float wg_osc(WgOsc *osc, float _phase);
54 void wg_init_osc(WgOsc *osc);
55 float wg_get_sample(WgOsc *chain, int num_oscs, float phase);
56