diff options
Diffstat (limited to 'plugins/LV2/src/Ditherbox')
-rw-r--r-- | plugins/LV2/src/Ditherbox/Ditherbox.cpp | 157 | ||||
-rw-r--r-- | plugins/LV2/src/Ditherbox/Ditherbox.h | 105 | ||||
-rw-r--r-- | plugins/LV2/src/Ditherbox/Ditherbox.ttl | 70 | ||||
-rw-r--r-- | plugins/LV2/src/Ditherbox/manifest.ttl.in | 6 |
4 files changed, 338 insertions, 0 deletions
diff --git a/plugins/LV2/src/Ditherbox/Ditherbox.cpp b/plugins/LV2/src/Ditherbox/Ditherbox.cpp new file mode 100644 index 0000000..682fc81 --- /dev/null +++ b/plugins/LV2/src/Ditherbox/Ditherbox.cpp @@ -0,0 +1,157 @@ +#include "Ditherbox.h" +#include <iostream> +#include <lv2wrapper.h> + +Ditherbox::Ditherbox(double rate) + : LV2Plugin(rate) +{ +} + +void Ditherbox::activate() +{ + A = 0.86; + + Position = 99999999; + contingentErrL = 0.0; + contingentErrR = 0.0; + currentDitherL = 0.0; + currentDitherR = 0.0; + bynL[0] = 1000; + bynL[1] = 301; + bynL[2] = 176; + bynL[3] = 125; + bynL[4] = 97; + bynL[5] = 79; + bynL[6] = 67; + bynL[7] = 58; + bynL[8] = 51; + bynL[9] = 46; + bynL[10] = 1000; + noiseShapingL = 0.0; + bynR[0] = 1000; + bynR[1] = 301; + bynR[2] = 176; + bynR[3] = 125; + bynR[4] = 97; + bynR[5] = 79; + bynR[6] = 67; + bynR[7] = 58; + bynR[8] = 51; + bynR[9] = 46; + bynR[10] = 1000; + noiseShapingR = 0.0; + + NSOddL = 0.0; + prevL = 0.0; + nsL[0] = 0; + nsL[1] = 0; + nsL[2] = 0; + nsL[3] = 0; + nsL[4] = 0; + nsL[5] = 0; + nsL[6] = 0; + nsL[7] = 0; + nsL[8] = 0; + nsL[9] = 0; + nsL[10] = 0; + nsL[11] = 0; + nsL[12] = 0; + nsL[13] = 0; + nsL[14] = 0; + nsL[15] = 0; + NSOddR = 0.0; + prevR = 0.0; + nsR[0] = 0; + nsR[1] = 0; + nsR[2] = 0; + nsR[3] = 0; + nsR[4] = 0; + nsR[5] = 0; + nsR[6] = 0; + nsR[7] = 0; + nsR[8] = 0; + nsR[9] = 0; + nsR[10] = 0; + nsR[11] = 0; + nsR[12] = 0; + nsR[13] = 0; + nsR[14] = 0; + nsR[15] = 0; + + lastSampleL = 0.0; + outSampleL = 0.0; + lastSampleR = 0.0; + outSampleR = 0.0; + + iirSampleAL = 0.0; + iirSampleBL = 0.0; + iirSampleCL = 0.0; + iirSampleDL = 0.0; + iirSampleEL = 0.0; + iirSampleFL = 0.0; + iirSampleGL = 0.0; + iirSampleHL = 0.0; + iirSampleIL = 0.0; + iirSampleJL = 0.0; + iirSampleKL = 0.0; + iirSampleLL = 0.0; + iirSampleML = 0.0; + iirSampleNL = 0.0; + iirSampleOL = 0.0; + iirSamplePL = 0.0; + iirSampleQL = 0.0; + iirSampleRL = 0.0; + iirSampleSL = 0.0; + iirSampleTL = 0.0; + iirSampleUL = 0.0; + iirSampleVL = 0.0; + iirSampleWL = 0.0; + iirSampleXL = 0.0; + iirSampleYL = 0.0; + iirSampleZL = 0.0; + + iirSampleAR = 0.0; + iirSampleBR = 0.0; + iirSampleCR = 0.0; + iirSampleDR = 0.0; + iirSampleER = 0.0; + iirSampleFR = 0.0; + iirSampleGR = 0.0; + iirSampleHR = 0.0; + iirSampleIR = 0.0; + iirSampleJR = 0.0; + iirSampleKR = 0.0; + iirSampleLR = 0.0; + iirSampleMR = 0.0; + iirSampleNR = 0.0; + iirSampleOR = 0.0; + iirSamplePR = 0.0; + iirSampleQR = 0.0; + iirSampleRR = 0.0; + iirSampleSR = 0.0; + iirSampleTR = 0.0; + iirSampleUR = 0.0; + iirSampleVR = 0.0; + iirSampleWR = 0.0; + iirSampleXR = 0.0; + iirSampleYR = 0.0; + iirSampleZR = 0.0; + //this is reset: values being initialized only once. Startup values, whatever they are. + +} + +void Ditherbox::run(uint32_t num_samples) +{ + A = *params[0]; + + processReplacing(const_cast<float **>(in), out, num_samples); +} + +// +// Include the processing code from the VST version. +// +#include <cmath> +#include "../../../LinuxVST/src/Ditherbox/DitherboxProc.cpp" + +// Create the LV2Wrapper and register the plugin +LV2Wrapper<Ditherbox> plugin; diff --git a/plugins/LV2/src/Ditherbox/Ditherbox.h b/plugins/LV2/src/Ditherbox/Ditherbox.h new file mode 100644 index 0000000..fb81642 --- /dev/null +++ b/plugins/LV2/src/Ditherbox/Ditherbox.h @@ -0,0 +1,105 @@ +#ifndef __Ditherbox_H +#define __Ditherbox_H + +#include <lv2plugin.h> + +class Ditherbox : public LV2Plugin<1> { +public: + Ditherbox(double rate); + + void activate(); + void run(uint32_t num_samples); + + static constexpr const char * URI = "https://www.airwindows.com/ditherbox"; + +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); + + /* + * Members needed by the processing functions. + */ + + double bynL[13]; + double bynR[13]; + long double noiseShapingL; + long double noiseShapingR; + double contingentErrL; + double contingentErrR; + double currentDitherL; + double currentDitherR; + int Position; + bool flip; + double NSOddL; + double prevL; + double nsL[16]; + double NSOddR; + double prevR; + double nsR[16]; + long double lastSampleL; + long double outSampleL; + long double lastSampleR; + long double outSampleR; + + double iirSampleAL; + double iirSampleBL; + double iirSampleCL; + double iirSampleDL; + double iirSampleEL; + double iirSampleFL; + double iirSampleGL; + double iirSampleHL; + double iirSampleIL; + double iirSampleJL; + double iirSampleKL; + double iirSampleLL; + double iirSampleML; + double iirSampleNL; + double iirSampleOL; + double iirSamplePL; + double iirSampleQL; + double iirSampleRL; + double iirSampleSL; + double iirSampleTL; + double iirSampleUL; + double iirSampleVL; + double iirSampleWL; + double iirSampleXL; + double iirSampleYL; + double iirSampleZL; + + double iirSampleAR; + double iirSampleBR; + double iirSampleCR; + double iirSampleDR; + double iirSampleER; + double iirSampleFR; + double iirSampleGR; + double iirSampleHR; + double iirSampleIR; + double iirSampleJR; + double iirSampleKR; + double iirSampleLR; + double iirSampleMR; + double iirSampleNR; + double iirSampleOR; + double iirSamplePR; + double iirSampleQR; + double iirSampleRR; + double iirSampleSR; + double iirSampleTR; + double iirSampleUR; + double iirSampleVR; + double iirSampleWR; + double iirSampleXR; + double iirSampleYR; + double iirSampleZR; + + float A; +}; + +#endif diff --git a/plugins/LV2/src/Ditherbox/Ditherbox.ttl b/plugins/LV2/src/Ditherbox/Ditherbox.ttl new file mode 100644 index 0000000..9b6880e --- /dev/null +++ b/plugins/LV2/src/Ditherbox/Ditherbox.ttl @@ -0,0 +1,70 @@ +# Airwindows Ditherbox 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/ditherbox> + a lv2:Plugin , + lv2:EffectsPlugin ; + 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 "Type" ; + lv2:default 0.5 ; + lv2:minimum 0.0 ; + lv2:maximum 1.0 ; + lv2:portProperty lv2:integer, lv2:enumeration ; + lv2:scalePoint [ rdfs:label "Trunc16" ; rdf:value 0.0 ] ; + lv2:scalePoint [ rdfs:label "Flat16" ; rdf:value 0.044 ] ; + lv2:scalePoint [ rdfs:label "TPDF16" ; rdf:value 0.084 ] ; + lv2:scalePoint [ rdfs:label "Paul16" ; rdf:value 0.124 ] ; + lv2:scalePoint [ rdfs:label "DbPaul16" ; rdf:value 0.164 ] ; + lv2:scalePoint [ rdfs:label "Tape16" ; rdf:value 0.202 ] ; + lv2:scalePoint [ rdfs:label "HiGloss16" ; rdf:value 0.244 ] ; + lv2:scalePoint [ rdfs:label "Vinyl16" ; rdf:value 0.284 ] ; + lv2:scalePoint [ rdfs:label "Spatial16" ; rdf:value 0.324 ] ; + lv2:scalePoint [ rdfs:label "Natural16" ; rdf:value 0.364 ] ; + lv2:scalePoint [ rdfs:label "NJAD16" ; rdf:value 0.404 ] ; + lv2:scalePoint [ rdfs:label "Trunc24" ; rdf:value 0.444 ] ; + lv2:scalePoint [ rdfs:label "Flat24" ; rdf:value 0.484 ] ; + lv2:scalePoint [ rdfs:label "TPDF24" ; rdf:value 0.524 ] ; + lv2:scalePoint [ rdfs:label "Paul24" ; rdf:value 0.564 ] ; + lv2:scalePoint [ rdfs:label "DbPaul24" ; rdf:value 0.604 ] ; + lv2:scalePoint [ rdfs:label "Tape24" ; rdf:value 0.644 ] ; + lv2:scalePoint [ rdfs:label "HiGloss24" ; rdf:value 0.684 ] ; + lv2:scalePoint [ rdfs:label "Vinyl24" ; rdf:value 0.724 ] ; + lv2:scalePoint [ rdfs:label "Spatial24" ; rdf:value 0.764 ] ; + lv2:scalePoint [ rdfs:label "Natural24" ; rdf:value 0.804 ] ; + lv2:scalePoint [ rdfs:label "NJAD24" ; rdf:value 0.844 ] ; + lv2:scalePoint [ rdfs:label "SlewOnly" ; rdf:value 0.884 ] ; + lv2:scalePoint [ rdfs:label "SubsOnly" ; rdf:value 0.924 ] ; + lv2:scalePoint [ rdfs:label "Silhouette" ; rdf:value 0.964 ] ; + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index 1 ; + lv2:symbol "in_l" ; + lv2:name "In left" ; + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index 2 ; + lv2:symbol "in_r" ; + lv2:name "In right" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index 3 ; + lv2:symbol "out_l" ; + lv2:name "Out left" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index 4 ; + lv2:symbol "out_r" ; + lv2:name "Out right" ; + ] . diff --git a/plugins/LV2/src/Ditherbox/manifest.ttl.in b/plugins/LV2/src/Ditherbox/manifest.ttl.in new file mode 100644 index 0000000..dcf3e34 --- /dev/null +++ b/plugins/LV2/src/Ditherbox/manifest.ttl.in @@ -0,0 +1,6 @@ +airwindows:ditherbox + a lv2:Plugin ; + doap:name "Airwindows Ditherbox" ; + doap:license <http://opensource.org/licenses/mit> ; + lv2:binary <Ditherbox@CMAKE_SHARED_LIBRARY_SUFFIX@> ; + rdfs:seeAlso <Ditherbox.ttl> . |