aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/LV2/src/Acceleration/Acceleration.cpp155
-rw-r--r--plugins/LV2/src/Acceleration/Acceleration.h21
-rw-r--r--plugins/LV2/src/Acceleration/lv2wrapper.cpp70
3 files changed, 131 insertions, 115 deletions
diff --git a/plugins/LV2/src/Acceleration/Acceleration.cpp b/plugins/LV2/src/Acceleration/Acceleration.cpp
index 9be24cd..dcc8734 100644
--- a/plugins/LV2/src/Acceleration/Acceleration.cpp
+++ b/plugins/LV2/src/Acceleration/Acceleration.cpp
@@ -1,135 +1,60 @@
-#include "lv2/core/lv2.h"
-
+#include "Acceleration.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,
+enum class PortIndex : uint32_t {
+ LIMIT,
+ DRYWET,
+ IN_L,
+ IN_R,
+ OUT_L,
+ OUT_R,
};
-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];
- float * out[2];
-};
-
-LV2_Handle instantiate(
- const LV2_Descriptor * d,
- double rate,
- const char * path,
- const LV2_Feature * const * features)
-{
- return new Acceleration{rate};
-}
+} // anon namespace
-void connect_port(
- LV2_Handle instance,
- uint32_t port,
- void * data)
+Acceleration::Acceleration(double rate)
+ : rate(rate)
{
- auto accel = static_cast<Acceleration *>(instance);
- accel->connect_port(port, data);
}
-void activate(LV2_Handle instance)
+void Acceleration::connect_port(uint32_t port, void * data)
{
-}
+ switch (static_cast<PortIndex>(port)) {
+ case PortIndex::LIMIT:
+ limit = (const float *) data;
+ break;
-void run(LV2_Handle instance, uint32_t num_samples)
-{
- auto accel = static_cast<Acceleration *>(instance);
- accel->run(num_samples);
-}
+ case PortIndex::DRYWET:
+ drywet = (const float *) data;
+ break;
-void deactivate(LV2_Handle)
-{
-}
+ case PortIndex::IN_L:
+ in[0] = (const float *) data;
+ break;
-void destroy(LV2_Handle instance)
-{
- delete static_cast<Acceleration *>(instance);
-}
+ case PortIndex::IN_R:
+ in[1] = (const float *) data;
+ break;
-const void * extension_data(const char * uri)
-{
- return nullptr;
-}
+ case PortIndex::OUT_L:
+ out[0] = (float *) data;
+ break;
-const LV2_Descriptor descriptor = {
- ACCELERATION_URI,
- instantiate,
- connect_port,
- activate,
- run,
- deactivate,
- destroy,
- extension_data
-};
+ case PortIndex::OUT_R:
+ out[1] = (float *) data;
+ break;
-} // anon namespace
+ default:
+ std::cerr << "Invalid port " << port << ": ignoring." << std::endl;
+ }
+}
-LV2_SYMBOL_EXPORT
-const LV2_Descriptor * lv2_descriptor(uint32_t idx)
+void Acceleration::run(uint32_t num_samples)
{
- if (idx == 0)
- return &descriptor;
-
- return nullptr;
+ for (auto i = 0u; i < num_samples; i++) {
+ *out[0]++ = *in[0]++ * *limit;
+ *out[1]++ = *in[1]++ * *limit;
+ }
}
diff --git a/plugins/LV2/src/Acceleration/Acceleration.h b/plugins/LV2/src/Acceleration/Acceleration.h
new file mode 100644
index 0000000..c277cb9
--- /dev/null
+++ b/plugins/LV2/src/Acceleration/Acceleration.h
@@ -0,0 +1,21 @@
+#ifndef __Acceleration_h
+#define __Acceleration_h
+
+#include <cstdint>
+
+class Acceleration {
+public:
+ Acceleration(double rate);
+
+ void connect_port(uint32_t port, void * data);
+ void run(uint32_t num_samples);
+
+private:
+ double rate;
+ const float * limit;
+ const float * drywet;
+ const float * in[2];
+ float * out[2];
+};
+
+#endif
diff --git a/plugins/LV2/src/Acceleration/lv2wrapper.cpp b/plugins/LV2/src/Acceleration/lv2wrapper.cpp
new file mode 100644
index 0000000..3b1c04c
--- /dev/null
+++ b/plugins/LV2/src/Acceleration/lv2wrapper.cpp
@@ -0,0 +1,70 @@
+#include "lv2/core/lv2.h"
+#include "Acceleration.h"
+
+namespace {
+
+const char * ACCELERATION_URI = "https://www.airwindows.com/acceleration";
+
+LV2_Handle instantiate(
+ const LV2_Descriptor * d,
+ double rate,
+ const char * path,
+ const LV2_Feature * const * features)
+{
+ return new Acceleration{rate};
+}
+
+void connect_port(
+ LV2_Handle instance,
+ uint32_t port,
+ void * data)
+{
+ auto accel = static_cast<Acceleration *>(instance);
+ accel->connect_port(port, data);
+}
+
+void activate(LV2_Handle instance)
+{
+}
+
+void run(LV2_Handle instance, uint32_t num_samples)
+{
+ auto accel = static_cast<Acceleration *>(instance);
+ accel->run(num_samples);
+}
+
+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;
+}