forked from nicklan/drmr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drmr.h
182 lines (160 loc) · 3.58 KB
/
drmr.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* drmr.h
* LV2 DrMr plugin
* Copyright 2012 Nick Lanham <nick@afternight.org>
*
* Public License v3. source code is available at
* <http://github.com/nicklan/drmr>
* THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef DRMR_H
#define DRMR_H
#include <sndfile.h>
#include <pthread.h>
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "lv2/lv2plug.in/ns/ext/event/event.h"
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
// drumkit scanned from a hydrogen xml file
typedef struct {
char* name;
char* desc;
char* path;
char** sample_names;
int samples;
} scanned_kit;
typedef struct {
int num_kits;
scanned_kit* kits;
} kits;
// libsndfile stuff
typedef struct {
float min;
float max;
SF_INFO *info;
uint32_t limit;
float* data;
} drmr_layer;
typedef struct {
SF_INFO *info;
char active;
uint32_t offset;
uint32_t limit;
uint32_t layer_count;
float velocity;
drmr_layer *layers;
float* data;
} drmr_sample;
// lv2 stuff
#define DRMR_URI "http://github.com/nicklan/drmr"
#define GAIN_MIN -60.0f
#define GAIN_MAX 6.0f
typedef enum {
DRMR_MIDI = 0,
DRMR_LEFT,
DRMR_RIGHT,
DRMR_KITNUM,
DRMR_BASENOTE,
DRMR_GAIN_ONE,
DRMR_GAIN_TWO,
DRMR_GAIN_THREE,
DRMR_GAIN_FOUR,
DRMR_GAIN_FIVE,
DRMR_GAIN_SIX,
DRMR_GAIN_SEVEN,
DRMR_GAIN_EIGHT,
DRMR_GAIN_NINE,
DRMR_GAIN_TEN,
DRMR_GAIN_ELEVEN,
DRMR_GAIN_TWELVE,
DRMR_GAIN_THIRTEEN,
DRMR_GAIN_FOURTEEN,
DRMR_GAIN_FIFTEEN,
DRMR_GAIN_SIXTEEN,
DRMR_GAIN_SEVENTEEN,
DRMR_GAIN_EIGHTEEN,
DRMR_GAIN_NINETEEN,
DRMR_GAIN_TWENTY,
DRMR_GAIN_TWENTYONE,
DRMR_GAIN_TWENTYTWO,
DRMR_GAIN_TWENTYTHREE,
DRMR_GAIN_TWENTYFOUR,
DRMR_GAIN_TWENTYFIVE,
DRMR_GAIN_TWENTYSIX,
DRMR_GAIN_TWENTYSEVEN,
DRMR_GAIN_TWENTYEIGHT,
DRMR_GAIN_TWENTYNINE,
DRMR_GAIN_THIRTY,
DRMR_GAIN_THIRTYONE,
DRMR_GAIN_THIRTYTWO,
DRMR_PAN_ONE,
DRMR_PAN_TWO,
DRMR_PAN_THREE,
DRMR_PAN_FOUR,
DRMR_PAN_FIVE,
DRMR_PAN_SIX,
DRMR_PAN_SEVEN,
DRMR_PAN_EIGHT,
DRMR_PAN_NINE,
DRMR_PAN_TEN,
DRMR_PAN_ELEVEN,
DRMR_PAN_TWELVE,
DRMR_PAN_THIRTEEN,
DRMR_PAN_FOURTEEN,
DRMR_PAN_FIFTEEN,
DRMR_PAN_SIXTEEN,
DRMR_PAN_SEVENTEEN,
DRMR_PAN_EIGHTEEN,
DRMR_PAN_NINETEEN,
DRMR_PAN_TWENTY,
DRMR_PAN_TWENTYONE,
DRMR_PAN_TWENTYTWO,
DRMR_PAN_TWENTYTHREE,
DRMR_PAN_TWENTYFOUR,
DRMR_PAN_TWENTYFIVE,
DRMR_PAN_TWENTYSIX,
DRMR_PAN_TWENTYSEVEN,
DRMR_PAN_TWENTYEIGHT,
DRMR_PAN_TWENTYNINE,
DRMR_PAN_THIRTY,
DRMR_PAN_THIRTYONE,
DRMR_PAN_THIRTYTWO,
DRMR_IGNORE_VELOCITY,
DRMR_IGNORE_NOTE_OFF,
DRMR_NUM_PORTS
} DrMrPortIndex;
typedef struct {
// Ports
float* left;
float* right;
LV2_Event_Buffer *midi_port;
// params
float** gains;
float** pans;
float* kitReq;
float* baseNote;
float* ignore_velocity;
float* ignore_note_off;
double rate;
// URIs
LV2_URI_Map_Feature* map;
struct {
uint32_t midi_event;
} uris;
// Available kits
kits* kits;
int curKit;
// Samples
drmr_sample* samples;
uint8_t num_samples;
// loading thread stuff
pthread_mutex_t load_mutex;
pthread_cond_t load_cond;
pthread_t load_thread;
} DrMr;
#endif // DRMR_H