aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-07-19 18:57:34 +0200
committerHarald Eilertsen <haraldei@anduin.net>2020-07-19 18:57:34 +0200
commit271d4c04271f63d565ff0ff96415106b2c121327 (patch)
tree4f9bc32f1e6a89eaae9705d01d79072338e3bde7
parent83254f1690123dc66991ce50c9db23c7cadba711 (diff)
downloadairwindows-lv2-port-271d4c04271f63d565ff0ff96415106b2c121327.tar.gz
airwindows-lv2-port-271d4c04271f63d565ff0ff96415106b2c121327.tar.bz2
airwindows-lv2-port-271d4c04271f63d565ff0ff96415106b2c121327.zip
LV2: Refactor common code to base class.
-rw-r--r--plugins/LV2/include/lv2plugin.h18
-rw-r--r--plugins/LV2/src/ADClip7/ADClip7.cpp12
-rw-r--r--plugins/LV2/src/ADClip7/ADClip7.h14
-rw-r--r--plugins/LV2/src/Acceleration/Acceleration.cpp12
-rw-r--r--plugins/LV2/src/Acceleration/Acceleration.h13
5 files changed, 32 insertions, 37 deletions
diff --git a/plugins/LV2/include/lv2plugin.h b/plugins/LV2/include/lv2plugin.h
new file mode 100644
index 0000000..f8ae4da
--- /dev/null
+++ b/plugins/LV2/include/lv2plugin.h
@@ -0,0 +1,18 @@
+// Required typa alias for VTS processing funcs.
+using VstInt32 = int32_t;
+
+class LV2Plugin
+{
+public:
+ LV2Plugin(double frame_rate)
+ : rate(frame_rate)
+ {}
+
+ double getSampleRate() const
+ {
+ return rate;
+ }
+
+private:
+ double rate;
+};
diff --git a/plugins/LV2/src/ADClip7/ADClip7.cpp b/plugins/LV2/src/ADClip7/ADClip7.cpp
index adf6eb9..11c8c27 100644
--- a/plugins/LV2/src/ADClip7/ADClip7.cpp
+++ b/plugins/LV2/src/ADClip7/ADClip7.cpp
@@ -19,7 +19,7 @@ enum class PortIndex : uint32_t {
} // anon namespace
ADClip7::ADClip7(double rate)
- : rate(rate)
+ : LV2Plugin(rate)
, refclipL(0.99)
, refclipR(0.99)
{
@@ -76,16 +76,6 @@ void ADClip7::run(uint32_t num_samples)
}
//
-// Helper functions to satisfy the processing code
-//
-
-double ADClip7::getSampleRate()
-{
- return rate;
-}
-
-
-//
// Include the processing code from the VST version.
//
#include "../../../LinuxVST/src/ADClip7/ADClip7Proc.cpp"
diff --git a/plugins/LV2/src/ADClip7/ADClip7.h b/plugins/LV2/src/ADClip7/ADClip7.h
index cfe7f40..e3d8474 100644
--- a/plugins/LV2/src/ADClip7/ADClip7.h
+++ b/plugins/LV2/src/ADClip7/ADClip7.h
@@ -2,11 +2,9 @@
#define __ADClip7_H
#include <cstdint>
+#include <lv2plugin.h>
-// Required typa alias for VTS processing funcs.
-using VstInt32 = int32_t;
-
-class ADClip7 {
+class ADClip7 : protected LV2Plugin {
public:
ADClip7(double rate);
@@ -16,13 +14,13 @@ public:
static constexpr const char * URI = "https://www.airwindows.com/adclip-7";
private:
+ /*
+ * These are the original DSP functions from the VST plugin.
+ * They need to be called from the LV2 plugins `run` function.
+ */
void processReplacing(float **in, float **out, VstInt32 samples);
void processDoubleReplacing(double **in, double **out, VstInt32 samples);
- double getSampleRate();
-
- double rate;
-
// Pointers to control ports
const float * boost;
const float * soften;
diff --git a/plugins/LV2/src/Acceleration/Acceleration.cpp b/plugins/LV2/src/Acceleration/Acceleration.cpp
index c873e53..840d0f3 100644
--- a/plugins/LV2/src/Acceleration/Acceleration.cpp
+++ b/plugins/LV2/src/Acceleration/Acceleration.cpp
@@ -16,7 +16,7 @@ enum class PortIndex : uint32_t {
} // anon namespace
Acceleration::Acceleration(double rate)
- : rate(rate)
+ : LV2Plugin(rate)
{
}
@@ -60,16 +60,6 @@ void Acceleration::run(uint32_t num_samples)
}
//
-// Helper functions to satisfy the processing code
-//
-
-double Acceleration::getSampleRate()
-{
- return rate;
-}
-
-
-//
// Include the processing code from the VST version.
//
#include <cmath>
diff --git a/plugins/LV2/src/Acceleration/Acceleration.h b/plugins/LV2/src/Acceleration/Acceleration.h
index 16efc9a..0971045 100644
--- a/plugins/LV2/src/Acceleration/Acceleration.h
+++ b/plugins/LV2/src/Acceleration/Acceleration.h
@@ -2,11 +2,9 @@
#define __Acceleration_H
#include <cstdint>
+#include <lv2plugin.h>
-// Required typa alias for VTS processing funcs.
-using VstInt32 = int32_t;
-
-class Acceleration {
+class Acceleration : protected LV2Plugin {
public:
Acceleration(double rate);
@@ -16,12 +14,13 @@ public:
static constexpr const char * URI = "https://www.airwindows.com/acceleration";
private:
+ /*
+ * These are the original DSP functions from the VST plugin.
+ * They need to be called from the LV2 plugins `run` function.
+ */
void processReplacing(float **in, float **out, VstInt32 samples);
void processDoubleReplacing(double **in, double **out, VstInt32 samples);
- double getSampleRate();
-
- double rate;
const float * limit;
const float * drywet;
const float * in[2];