-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
58 lines (45 loc) · 1.6 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>
#include <stdlib.h>
#include <string.h>
#include <ecl/ecl.h>
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
/* the interface to the plugin */
extern const LV2_Descriptor* lv2_descriptor(uint32_t index);
// Drive the plugin interface and see what it does.
int main(int argc, char **argv)
{
int i, j;
int num_descriptors = 10; // try for ten, resets to whatever we get
int num_handles_per_descriptor = 3; // fixed.
const LV2_Descriptor **lv2_desc =
malloc(sizeof(LV2_Descriptor*) * num_descriptors);
// Let's mimic how the plugin will be called.
for (i = 0; i < num_descriptors; i++) {
// call the "entry point" to the plugin.
lv2_desc[i] = lv2_descriptor(i);
printf("HOST: LV2_Descriptor: %p\n", lv2_desc[i]);
if (lv2_desc[i] == NULL) {
// Stop whenever the plugin wants us to stop or we hit the
// maximum number.
num_descriptors = i;
printf("HOST: Done getting %d descriptors!\n", num_descriptors);
break;
}
}
// Now, instantiate exactly X objects for each defined plugin
LV2_Handle **phandles = malloc(sizeof(LV2_Handle) * num_descriptors);
for (i = 0; i < num_descriptors; i++) {
phandles[i] = malloc(sizeof(LV2_Handle) * num_handles_per_descriptor);
// and then ask for X real handles from the specific plugin!
for (j = 0; j < num_handles_per_descriptor; j++) {
LV2_Handle *handle = phandles[i];
handle[j] =
lv2_desc[i]->instantiate(lv2_desc[i], 2.4, "/some/path", NULL);
printf("HOST: Got instance %p from LV2_Descriptor %p\n",
handle[j], phandles[i]);
}
}
printf("HOST: Shutting it all down.\n");
cl_shutdown();
return EXIT_SUCCESS;
}