-
Notifications
You must be signed in to change notification settings - Fork 1
/
faun.h
120 lines (102 loc) · 3.02 KB
/
faun.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#ifndef FAUN_H
#define FAUN_H
/* ___________
\_ _____/____ __ __ ____
| __) \__ \ | | \/ \
| \ / __ \| | / | \
\__ / (____ /____/|___| /
\/ \/ \/
Faun - A high-level C audio library
Copyright (c) 2022-2024 Karl Robillard
This code may be used under the terms of the MIT license (see faun.c).
*/
#include <stdint.h>
#include <stdio.h>
#define FAUN_VERSION_STR "0.1.5"
#define FAUN_VERSION 0x000105
enum FaunCommand {
FC_START,
FC_STOP,
FC_RESUME,
FC_FADE_OUT,
FC_COUNT
};
enum FaunOpcode {
FO_END,
FO_WAIT, // 1/10 second units
FO_SOURCE, // Source #
FO_QUEUE, // Buffer #
FO_PLAY_BUF, // Buffer #, mode
FO_STREAM_ONCE,
FO_STREAM_LOOP,
FO_SET_VOL, // Unit value
FO_SET_PAN, // (-127=left 0=center 127=right)
FO_SET_FADE, // 1/10 second units
FO_SET_END, // 1/10 second units
FO_LOOP_ON,
FO_LOOP_OFF,
FO_FADE_IN,
FO_FADE_OUT,
FO_SIGNAL,
FO_CAPTURE,
FO_COUNT
};
#define FAUN_PROGRAM_MAX 64
enum FaunFormat {
FAUN_FMT_S16 = 1,
FAUN_FMT_F32 = 2,
FAUN_FMT_MONO = 0,
FAUN_FMT_STEREO = 8,
FAUN_FMT_22050 = 0x10,
FAUN_FMT_44100 = 0x20
};
enum FaunPlayMode {
FAUN_PLAY_ONCE = 0x0001,
FAUN_PLAY_LOOP = 0x0002,
FAUN_PLAY_FADE_IN = 0x0010,
FAUN_PLAY_FADE_OUT = 0x0020,
FAUN_SIGNAL_DONE = 0x0040,
FAUN_SIGNAL_PROG = 0x0080,
FAUN_PLAY_FADE = FAUN_PLAY_FADE_IN | FAUN_PLAY_FADE_OUT
};
#define FAUN_PAIR(a,b) (((b+1) << 10) | a)
#define FAUN_TRIO(a,b,c) (((c+1) << 20) | ((b+1) << 10) | a)
enum FaunParameter {
FAUN_VOLUME,
FAUN_PAN,
FAUN_FADE_PERIOD,
FAUN_END_TIME,
FAUN_PARAM_COUNT
};
typedef struct {
uint16_t id;
uint16_t signal;
}
FaunSignal;
#ifdef __cplusplus
extern "C" {
#endif
const char* faun_startup(int bufferLimit, int sourceLimit,
int streamLimit, int progLimit, const char* appName);
void faun_shutdown();
void faun_suspend(int halt);
void faun_setErrorStream(FILE*);
int faun_pollSignals(FaunSignal* sigbuf, int count);
void faun_waitSignal(FaunSignal* sigbuf);
void faun_control(int si, int count, int command);
void faun_setParameter(int si, int count, uint8_t param, float value);
void faun_program(int ei, const uint8_t* bytecode, int len);
float faun_loadBuffer(int bi, const char* file, uint32_t offset, uint32_t size);
float faun_loadBufferF(int bi, FILE* file, uint32_t size);
float faun_loadBufferPcm(int bi, int format, const void* samples,
uint32_t frames);
float faun_loadBufferSfx(int bi, const void* sfxParam);
void faun_freeBuffers(int bi, int count);
void faun_playSource(int si, int bi, int mode);
void faun_playStream(int si, const char* file, uint32_t offset,
uint32_t size, int mode);
void faun_playStreamPart(int si, double start, double duration, int mode);
#ifdef __cplusplus
}
#endif
#endif // FAUN_H