aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-07-16 23:08:11 +0200
committerHarald Eilertsen <haraldei@anduin.net>2020-07-16 23:08:11 +0200
commited1c33f8a60b2e34c78473c2c1392fb3b809e524 (patch)
tree9ae906ec99a78073ede65a4544123f577abe352b
parent8d8d55aba4c5388fff3681db268cefecd548367a (diff)
downloadairwindows-lv2-port-ed1c33f8a60b2e34c78473c2c1392fb3b809e524.tar.gz
airwindows-lv2-port-ed1c33f8a60b2e34c78473c2c1392fb3b809e524.tar.bz2
airwindows-lv2-port-ed1c33f8a60b2e34c78473c2c1392fb3b809e524.zip
LV2: Move actual processing into Acceleration class.
-rw-r--r--plugins/LV2/src/Acceleration/Acceleration.cpp84
1 files changed, 50 insertions, 34 deletions
diff --git a/plugins/LV2/src/Acceleration/Acceleration.cpp b/plugins/LV2/src/Acceleration/Acceleration.cpp
index 669df75..9be24cd 100644
--- a/plugins/LV2/src/Acceleration/Acceleration.cpp
+++ b/plugins/LV2/src/Acceleration/Acceleration.cpp
@@ -17,6 +17,53 @@ enum PortIndex {
class Acceleration {
public:
+ Acceleration(double rate)
+ : rate(rate)
+ {
+ }
+
+ void connect_port(uint32_t port, void * data)
+ {
+ switch (port) {
+ case ACCELERATION_LIMIT:
+ limit = (const float *) data;
+ break;
+
+ case ACCELERATION_DRYWET:
+ drywet = (const float *) data;
+ break;
+
+ case ACCELERATION_IN_L:
+ in[0] = (const float *) data;
+ break;
+
+ case ACCELERATION_IN_R:
+ in[1] = (const float *) data;
+ break;
+
+ case ACCELERATION_OUT_L:
+ out[0] = (float *) data;
+ break;
+
+ case ACCELERATION_OUT_R:
+ out[1] = (float *) data;
+ break;
+
+ default:
+ std::cerr << "Invalid port " << port << ": ignoring." << std::endl;
+ }
+ }
+
+ void run(uint32_t num_samples)
+ {
+ for (auto i = 0u; i < num_samples; i++) {
+ *out[0]++ = *in[0]++ * *limit;
+ *out[1]++ = *in[1]++ * *limit;
+ }
+ }
+
+private:
+ double rate;
const float * limit;
const float * drywet;
const float * in[2];
@@ -29,7 +76,7 @@ LV2_Handle instantiate(
const char * path,
const LV2_Feature * const * features)
{
- return new Acceleration{};
+ return new Acceleration{rate};
}
void connect_port(
@@ -38,35 +85,7 @@ void connect_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;
- }
+ accel->connect_port(port, data);
}
void activate(LV2_Handle instance)
@@ -76,10 +95,7 @@ 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]++;
- }
+ accel->run(num_samples);
}
void deactivate(LV2_Handle)