forked from kometbomb/klystrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwavegen.h
55 lines (46 loc) · 822 Bytes
/
wavegen.h
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
#pragma once
#include "SDL.h"
#define WG_CHAIN_OSCS 4
typedef enum
{
WG_OSC_SINE,
WG_OSC_SQUARE,
WG_OSC_SAW,
WG_OSC_TRIANGLE,
WG_OSC_NOISE,
WG_NUM_OSCS
} WgOscType;
typedef enum
{
WG_OP_ADD,
WG_OP_MUL,
WG_NUM_OPS
} WgOpType;
typedef struct
{
WgOscType osc;
WgOpType op;
int mult, shift;
int exp;
float exp_c;
Uint32 flags;
} WgOsc;
enum
{
WG_OSC_FLAG_ABS = 1,
WG_OSC_FLAG_NEG = 2
};
typedef struct
{
WgOsc chain[WG_CHAIN_OSCS];
int num_oscs, length;
} WgSettings;
typedef struct
{
const char *name;
WgSettings settings;
} WgPreset;
void wg_gen_waveform(WgOsc *chain, int num_oscs, Sint16 *data, int len);
float wg_osc(WgOsc *osc, float _phase);
void wg_init_osc(WgOsc *osc);
float wg_get_sample(WgOsc *chain, int num_oscs, float phase);