aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2020-07-18 19:02:26 +0200
committerHarald Eilertsen <haraldei@anduin.net>2020-07-18 19:02:26 +0200
commit225608fe4a2370a08e80db0b72f70a56fbcf5060 (patch)
tree7272a563818b527dd34a9b844672d427886b32c9
parentc7aae3b8ad576ae0f69693da21d1e5a40780f9b4 (diff)
downloadairwindows-lv2-port-225608fe4a2370a08e80db0b72f70a56fbcf5060.tar.gz
airwindows-lv2-port-225608fe4a2370a08e80db0b72f70a56fbcf5060.tar.bz2
airwindows-lv2-port-225608fe4a2370a08e80db0b72f70a56fbcf5060.zip
LV2: Port plugin ADClip7.
See https://www.airwindows.com/adclip-7/ for a great introduction to what this plugin does.
-rwxr-xr-xplugins/LV2/CMakeLists.txt2
-rw-r--r--plugins/LV2/src/ADClip7/ADClip7.cpp90
-rw-r--r--plugins/LV2/src/ADClip7/ADClip7.h60
-rw-r--r--plugins/LV2/src/ADClip7/ADClip7.ttl72
-rw-r--r--plugins/LV2/src/ADClip7/lv2wrapper.cpp70
-rw-r--r--plugins/LV2/src/ADClip7/manifest.ttl.in12
6 files changed, 305 insertions, 1 deletions
diff --git a/plugins/LV2/CMakeLists.txt b/plugins/LV2/CMakeLists.txt
index eca33f3..bd6ac57 100755
--- a/plugins/LV2/CMakeLists.txt
+++ b/plugins/LV2/CMakeLists.txt
@@ -8,7 +8,7 @@ include(Helpers.cmake)
# add_subdirectory(include/vstsdk)
add_airwindows_plugin(Acceleration)
-# add_airwindows_plugin(ADClip7)
+add_airwindows_plugin(ADClip7)
# add_airwindows_plugin(ADT)
# add_airwindows_plugin(Air)
# add_airwindows_plugin(Apicolypse)
diff --git a/plugins/LV2/src/ADClip7/ADClip7.cpp b/plugins/LV2/src/ADClip7/ADClip7.cpp
new file mode 100644
index 0000000..0c0891a
--- /dev/null
+++ b/plugins/LV2/src/ADClip7/ADClip7.cpp
@@ -0,0 +1,90 @@
+#include "ADClip7.h"
+#include <cmath>
+#include <iostream>
+
+namespace {
+
+enum class PortIndex : uint32_t {
+ BOOST,
+ SOFTEN,
+ ENHANCE,
+ MODE,
+ IN_L,
+ IN_R,
+ OUT_L,
+ OUT_R,
+};
+
+} // anon namespace
+
+ADClip7::ADClip7(double rate)
+ : rate(rate)
+ , refclipL(0.99)
+ , refclipR(0.99)
+{
+}
+
+void ADClip7::connect_port(uint32_t port, void * data)
+{
+ switch (static_cast<PortIndex>(port)) {
+ case PortIndex::BOOST:
+ boost = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::SOFTEN:
+ soften = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::ENHANCE:
+ enhance = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::MODE:
+ mode = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::IN_L:
+ in[0] = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::IN_R:
+ in[1] = static_cast<const float *>(data);
+ break;
+
+ case PortIndex::OUT_L:
+ out[0] = static_cast<float *>(data);
+ break;
+
+ case PortIndex::OUT_R:
+ out[1] = static_cast<float *>(data);
+ break;
+
+ default:
+ std::cerr << "Invalid port " << port << ": ignoring." << std::endl;
+ }
+}
+
+void ADClip7::run(uint32_t num_samples)
+{
+ A = *boost;
+ B = *soften;
+ C = *enhance;
+ D = *mode;
+
+ processReplacing(const_cast<float **>(in), out, 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
new file mode 100644
index 0000000..3ec6033
--- /dev/null
+++ b/plugins/LV2/src/ADClip7/ADClip7.h
@@ -0,0 +1,60 @@
+#ifndef __ADClip7_H
+#define __ADClip7_H
+
+#include <cstdint>
+
+// Required typa alias for VTS processing funcs.
+using VstInt32 = int32_t;
+
+class ADClip7 {
+public:
+ ADClip7(double rate);
+
+ void connect_port(uint32_t port, void * data);
+ void run(uint32_t num_samples);
+
+private:
+ 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;
+ const float * enhance;
+ const float * mode;
+
+ // Pointer to audio buffers
+ const float * in[2];
+ float * out[2];
+
+ // Temp values used by the processing code
+ float A;
+ float B;
+ float C;
+ float D;
+
+ // To keep state between runs
+ long double fpNShapeL;
+ long double fpNShapeR;
+
+ //default stuff
+ long double lastSampleL;
+ long double lastSampleR;
+ float bL[22200];
+ float bR[22200];
+ int gcount;
+ double lowsL;
+ double lowsR;
+ double iirLowsAL;
+ double iirLowsAR;
+ double iirLowsBL;
+ double iirLowsBR;
+ long double refclipL;
+ long double refclipR;
+};
+
+#endif
diff --git a/plugins/LV2/src/ADClip7/ADClip7.ttl b/plugins/LV2/src/ADClip7/ADClip7.ttl
new file mode 100644
index 0000000..33ad268
--- /dev/null
+++ b/plugins/LV2/src/ADClip7/ADClip7.ttl
@@ -0,0 +1,72 @@
+# Airwindows ADClip7 plugin description
+
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix units: <http://lv2plug.in/ns/extensions/units#> .
+
+<https://www.airwindows.com/adclip-7>
+ a lv2:Plugin ,
+ lv2:CompressorPlugin ;
+ lv2:project <https://www.airwindows.com> ;
+
+ lv2:optionalFeature lv2:hardRTCapable ;
+
+ # Define the ports for this plugin.
+ lv2:port [
+ a lv2:InputPort , lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "A" ;
+ lv2:name "Boost" ;
+ lv2:default 0.0 ;
+ lv2:minimum 0.0 ;
+ lv2:maximum 1.0 ;
+ ] , [
+ a lv2:InputPort , lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "B" ;
+ lv2:name "Soften" ;
+ lv2:default 0.5 ;
+ lv2:minimum 0.0 ;
+ lv2:maximum 1.0 ;
+ ] , [
+ a lv2:InputPort , lv2:ControlPort ;
+ lv2:index 2 ;
+ lv2:symbol "C" ;
+ lv2:name "Enhance" ;
+ lv2:default 0.5 ;
+ lv2:minimum 0.0 ;
+ lv2:maximum 1.0 ;
+ ] , [
+ a lv2:InputPort , lv2:ControlPort ;
+ lv2:index 3 ;
+ lv2:symbol "D" ;
+ lv2:name "Mode" ;
+ lv2:default 0.0 ;
+ lv2:minimum 0.0 ;
+ lv2:maximum 1.0 ;
+ lv2:portProperty lv2:integer, lv2:enumeration ;
+ lv2:scalePoint [ rdfs:label "ADClip Normal" ; rdf:value 0.0 ] ;
+ lv2:scalePoint [ rdfs:label "Gain Match" ; rdf:value 0.34 ] ;
+ lv2:scalePoint [ rdfs:label "Clip Only" ; rdf:value 0.67 ] ;
+ ] , [
+ a lv2:InputPort , lv2:AudioPort ;
+ lv2:index 4 ;
+ lv2:symbol "in_l" ;
+ lv2:name "In left" ;
+ ] , [
+ a lv2:InputPort , lv2:AudioPort ;
+ lv2:index 5 ;
+ lv2:symbol "in_r" ;
+ lv2:name "In right" ;
+ ] , [
+ a lv2:OutputPort , lv2:AudioPort ;
+ lv2:index 6 ;
+ lv2:symbol "out_l" ;
+ lv2:name "Out left" ;
+ ] , [
+ a lv2:OutputPort , lv2:AudioPort ;
+ lv2:index 7 ;
+ lv2:symbol "out_r" ;
+ lv2:name "Out right" ;
+ ] .
diff --git a/plugins/LV2/src/ADClip7/lv2wrapper.cpp b/plugins/LV2/src/ADClip7/lv2wrapper.cpp
new file mode 100644
index 0000000..2ff55c8
--- /dev/null
+++ b/plugins/LV2/src/ADClip7/lv2wrapper.cpp
@@ -0,0 +1,70 @@
+#include "lv2/core/lv2.h"
+#include "ADClip7.h"
+
+namespace {
+
+const char * PLUGIN_URI = "https://www.airwindows.com/adclip-7";
+
+LV2_Handle instantiate(
+ const LV2_Descriptor * d,
+ double rate,
+ const char * path,
+ const LV2_Feature * const * features)
+{
+ return new ADClip7{rate};
+}
+
+void connect_port(
+ LV2_Handle instance,
+ uint32_t port,
+ void * data)
+{
+ auto accel = static_cast<ADClip7 *>(instance);
+ accel->connect_port(port, data);
+}
+
+void activate(LV2_Handle instance)
+{
+}
+
+void run(LV2_Handle instance, uint32_t num_samples)
+{
+ auto accel = static_cast<ADClip7 *>(instance);
+ accel->run(num_samples);
+}
+
+void deactivate(LV2_Handle)
+{
+}
+
+void destroy(LV2_Handle instance)
+{
+ delete static_cast<ADClip7 *>(instance);
+}
+
+const void * extension_data(const char * uri)
+{
+ return nullptr;
+}
+
+const LV2_Descriptor descriptor = {
+ PLUGIN_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;
+}
diff --git a/plugins/LV2/src/ADClip7/manifest.ttl.in b/plugins/LV2/src/ADClip7/manifest.ttl.in
new file mode 100644
index 0000000..bda5816
--- /dev/null
+++ b/plugins/LV2/src/ADClip7/manifest.ttl.in
@@ -0,0 +1,12 @@
+# LV2 Plugin manifest for airwindows ADClip7 plugin
+
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<https://www.airwindows.com/adclip-7>
+ a lv2:Plugin ;
+ doap:name "Airwindows ADClip7 Loudness Maximizer" ;
+ doap:license <http://opensource.org/licenses/mit> ;
+ lv2:binary <ADClip7@CMAKE_SHARED_LIBRARY_SUFFIX@> ;
+ rdfs:seeAlso <ADClip7.ttl> .