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
|
#include "lv2/core/lv2.h"
#include <iostream>
namespace {
const char * ACCELERATION_URI = "https://www.airwindows.com/acceleration";
enum PortIndex {
ACCELERATION_LIMIT,
ACCELERATION_DRYWET,
ACCELERATION_IN_L,
ACCELERATION_IN_R,
ACCELERATION_OUT_L,
ACCELERATION_OUT_R,
};
class Acceleration {
public:
const float * limit;
const float * drywet;
const float * in[2];
float * out[2];
};
LV2_Handle instantiate(
const LV2_Descriptor * d,
double rate,
const char * path,
const LV2_Feature * const * features)
{
return new Acceleration{};
}
void connect_port(
LV2_Handle instance,
uint32_t port,
void * data)
{
auto accel = static_cast<Acceleration *>(instance);
switch (port) {
case ACCELERATION_LIMIT:
accel->limit = (const float *) data;
break;
case ACCELERATION_DRYWET:
accel->limit = (const float *) data;
break;
case ACCELERATION_IN_L:
accel->in[0] = (const float *) data;
break;
case ACCELERATION_IN_R:
accel->in[1] = (const float *) data;
break;
case ACCELERATION_OUT_L:
accel->out[0] = (float *) data;
break;
case ACCELERATION_OUT_R:
accel->out[1] = (float *) data;
break;
default:
std::cerr << "Invalid port " << port << ": ignoring." << std::endl;
}
}
void activate(LV2_Handle instance)
{
}
void run(LV2_Handle instance, uint32_t num_samples)
{
auto accel = static_cast<Acceleration *>(instance);
for (auto i = 0u; i < num_samples; i++) {
*accel->out[0]++ = *accel->in[0]++;
*accel->out[1]++ = *accel->in[1]++;
}
}
void deactivate(LV2_Handle)
{
}
void destroy(LV2_Handle instance)
{
delete static_cast<Acceleration *>(instance);
}
const void * extension_data(const char * uri)
{
return nullptr;
}
const LV2_Descriptor descriptor = {
ACCELERATION_URI,
instantiate,
connect_port,
activate,
run,
deactivate,
destroy,
extension_data
};
} // anon namespace
LV2_SYMBOL_EXPORT
const LV2_Descriptor * lv2_descriptor(uint32_t idx)
{
if (idx == 0)
return &descriptor;
return nullptr;
}
|