-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
58 lines (53 loc) · 1.85 KB
/
main.c
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
#include <stdio.h> /* fprintf, stderr */
#include "utils.h" /* GetOption */
#include "components.h" /* * */
static inline uint8_t
Usage(void)
{
fprintf(stderr, "Usage: sunset COMPONENT ARGS\n");
fprintf(stderr, "Components:\n");
fprintf(stderr, " Generation: [Generates values on @play]\n");
fprintf(stderr, " osc (Oscillator)\n");
fprintf(stderr, " noise (Noise Generator)\n");
fprintf(stderr, " env (Envelope Generator)\n");
fprintf(stderr, " Processing: [Process audio values]\n");
fprintf(stderr, " vol (Amplifier/Attenuator)\n");
fprintf(stderr, " range (Compressor/Expander)\n");
fprintf(stderr, " flt (Filters)\n");
fprintf(stderr, " Macros: [Edits stream lines]\n");
fprintf(stderr, " cfg (Configurator)\n");
fprintf(stderr, " Tools: [Miscellaneous]\n");
fprintf(stderr, " mix (Mixer)\n");
fprintf(stderr, " out (WAV output)\n");
return 1;
}
int
main(int argc, char* argv[])
{
int ret = 0;
if (argc > 1)
{
const char* keys[9] = {"osc", "noise", "env",
"vol", "range", "flt",
"cfg",
"mix", "out"};
int (*const values[9])(int, char**) = {Osc, Noise, Env,
Vol, Range, Flt,
Cfg,
Mix, Out};
uint8_t component;
if (GetOption(argv[1], keys, 9, &component) == 0)
{
ret = values[component](argc - 1, &(argv[1]));
}
else
{
ret = Usage();
}
}
else
{
ret = Usage();
}
return ret;
}