From 225608fe4a2370a08e80db0b72f70a56fbcf5060 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 18 Jul 2020 19:02:26 +0200 Subject: LV2: Port plugin ADClip7. See https://www.airwindows.com/adclip-7/ for a great introduction to what this plugin does. --- plugins/LV2/CMakeLists.txt | 2 +- plugins/LV2/src/ADClip7/ADClip7.cpp | 90 +++++++++++++++++++++++++++++++++ plugins/LV2/src/ADClip7/ADClip7.h | 60 ++++++++++++++++++++++ plugins/LV2/src/ADClip7/ADClip7.ttl | 72 ++++++++++++++++++++++++++ plugins/LV2/src/ADClip7/lv2wrapper.cpp | 70 +++++++++++++++++++++++++ plugins/LV2/src/ADClip7/manifest.ttl.in | 12 +++++ 6 files changed, 305 insertions(+), 1 deletion(-) create mode 100644 plugins/LV2/src/ADClip7/ADClip7.cpp create mode 100644 plugins/LV2/src/ADClip7/ADClip7.h create mode 100644 plugins/LV2/src/ADClip7/ADClip7.ttl create mode 100644 plugins/LV2/src/ADClip7/lv2wrapper.cpp create mode 100644 plugins/LV2/src/ADClip7/manifest.ttl.in 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 +#include + +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(port)) { + case PortIndex::BOOST: + boost = static_cast(data); + break; + + case PortIndex::SOFTEN: + soften = static_cast(data); + break; + + case PortIndex::ENHANCE: + enhance = static_cast(data); + break; + + case PortIndex::MODE: + mode = static_cast(data); + break; + + case PortIndex::IN_L: + in[0] = static_cast(data); + break; + + case PortIndex::IN_R: + in[1] = static_cast(data); + break; + + case PortIndex::OUT_L: + out[0] = static_cast(data); + break; + + case PortIndex::OUT_R: + out[1] = static_cast(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(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 + +// 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: . +@prefix rdf: . +@prefix rdfs: . +@prefix units: . + + + a lv2:Plugin , + lv2:CompressorPlugin ; + lv2:project ; + + 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(instance); + accel->connect_port(port, data); +} + +void activate(LV2_Handle instance) +{ +} + +void run(LV2_Handle instance, uint32_t num_samples) +{ + auto accel = static_cast(instance); + accel->run(num_samples); +} + +void deactivate(LV2_Handle) +{ +} + +void destroy(LV2_Handle instance) +{ + delete static_cast(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: . +@prefix lv2: . +@prefix rdfs: . + + + a lv2:Plugin ; + doap:name "Airwindows ADClip7 Loudness Maximizer" ; + doap:license ; + lv2:binary ; + rdfs:seeAlso . -- cgit v1.2.3