summaryrefslogtreecommitdiff
path: root/plugins/ZaMultiCompX2
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2014-04-15 07:03:19 +1000
committerDamien Zammit <damien@zamaudio.com>2014-04-15 07:03:19 +1000
commit2f66cd7c71b2f1fae823f566f3bbe04f91a3c879 (patch)
treeab6640951b9d0111ccd27e288c20bf8f029e699e /plugins/ZaMultiCompX2
parentc52ca9317f6d263380436d8b52af9ab76f3d518a (diff)
Disabled VST build (stateless). Fixed meter refresh, adding graph.
Signed-off-by: Damien Zammit <damien@zamaudio.com>
Diffstat (limited to 'plugins/ZaMultiCompX2')
-rw-r--r--plugins/ZaMultiCompX2/DistrhoPluginInfo.h2
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp42
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp13
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp86
-rw-r--r--plugins/ZaMultiCompX2/ZaMultiCompX2UI.hpp5
5 files changed, 136 insertions, 12 deletions
diff --git a/plugins/ZaMultiCompX2/DistrhoPluginInfo.h b/plugins/ZaMultiCompX2/DistrhoPluginInfo.h
index 2770e27..94dc5e5 100644
--- a/plugins/ZaMultiCompX2/DistrhoPluginInfo.h
+++ b/plugins/ZaMultiCompX2/DistrhoPluginInfo.h
@@ -28,7 +28,7 @@
#define DISTRHO_PLUGIN_WANT_LATENCY 0
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1
-#define DISTRHO_PLUGIN_WANT_STATE 0
+#define DISTRHO_PLUGIN_WANT_STATE 1
#define DISTRHO_PLUGIN_WANT_TIMEPOS 0
#define DISTRHO_PLUGIN_URI "urn:zamaudio:ZaMultiCompX2"
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
index 1e5e6bd..4456b44 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.cpp
@@ -22,7 +22,7 @@ START_NAMESPACE_DISTRHO
// -----------------------------------------------------------------------
ZaMultiCompX2Plugin::ZaMultiCompX2Plugin()
- : Plugin(paramCount, 1, 0) // 1 program, 0 states
+ : Plugin(paramCount, 1, 1) // 1 program, 0 states
{
// set default values
d_setProgram(0);
@@ -386,21 +386,33 @@ void ZaMultiCompX2Plugin::d_setParameterValue(uint32_t index, float value)
break;
case paramToggle1:
toggle[0] = value;
+ if (value == 0.f)
+ gainr[0] = 0.f;
break;
case paramToggle2:
toggle[1] = value;
+ if (value == 0.f)
+ gainr[1] = 0.f;
break;
case paramToggle3:
toggle[2] = value;
+ if (value == 0.f)
+ gainr[2] = 0.f;
break;
case paramListen1:
listen[0] = value;
+ if (value == 0.f)
+ gainr[0] = 0.f;
break;
case paramListen2:
listen[1] = value;
+ if (value == 0.f)
+ gainr[1] = 0.f;
break;
case paramListen3:
listen[2] = value;
+ if (value == 0.f)
+ gainr[2] = 0.f;
break;
case paramGlobalGain:
globalgain = value;
@@ -446,6 +458,8 @@ void ZaMultiCompX2Plugin::d_setProgram(uint32_t index)
stereodet = 1.0f;
outl = -45.f;
outr = -45.f;
+ maxL = 0.f;
+ maxR = 0.f;
/* Default variable values */
@@ -453,6 +467,16 @@ void ZaMultiCompX2Plugin::d_setProgram(uint32_t index)
d_activate();
}
+void ZaMultiCompX2Plugin::d_setState(const char* key, const char* value)
+{
+ resetl = true;
+ resetr = true;
+}
+
+void ZaMultiCompX2Plugin::d_initStateKey(unsigned int key, d_string& val)
+{
+}
+
// -----------------------------------------------------------------------
// Process
@@ -645,8 +669,6 @@ void ZaMultiCompX2Plugin::d_run(float** inputs, float** outputs, uint32_t frames
float outR[MAX_COMP] = {0.f};
int listenmode = 0;
- maxL = 0.f;
- maxR = 0.f;
// Interleaved channel processing
fil1[0] = run_filter(0, 0, inputs[0][i]);
@@ -713,8 +735,18 @@ void ZaMultiCompX2Plugin::d_run(float** inputs, float** outputs, uint32_t frames
outputs[0][i] *= from_dB(globalgain);
outputs[1][i] *= from_dB(globalgain);
- maxL = (fabsf(outputs[0][i]) > maxL) ? fabsf(outputs[0][i]) : maxL;
- maxR = (fabsf(outputs[1][i]) > maxR) ? fabsf(outputs[1][i]) : maxR;
+ if (resetl) {
+ maxL = fabsf(outputs[0][i]);
+ resetl = false;
+ } else {
+ maxL = (fabsf(outputs[0][i]) > maxL) ? fabsf(outputs[0][i]) : maxL;
+ }
+ if (resetr) {
+ maxR = fabsf(outputs[1][i]);
+ resetr = false;
+ } else {
+ maxR = (fabsf(outputs[1][i]) > maxR) ? fabsf(outputs[1][i]) : maxR;
+ }
}
outl = sanitize_denormal((maxL == 0.f) ? -45.f : to_dB(maxL));
outr = sanitize_denormal((maxR == 0.f) ? -45.f : to_dB(maxR));
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
index 975e303..6fae674 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2Plugin.hpp
@@ -67,10 +67,17 @@ public:
paramOutputLevelR,
paramCount
};
+
+ enum States
+ {
+ stateReadMeter,
+ stateCount
+ };
ZaMultiCompX2Plugin();
~ZaMultiCompX2Plugin() override;
+
protected:
// -------------------------------------------------------------------
// Information
@@ -105,6 +112,7 @@ protected:
void d_initParameter(uint32_t index, Parameter& parameter) ;
void d_initProgramName(uint32_t index, d_string& programName) ;
+ void d_initStateKey(uint32_t, d_string&) override;
// -------------------------------------------------------------------
// Internal data
@@ -112,6 +120,7 @@ protected:
float d_getParameterValue(uint32_t index) const override;
void d_setParameterValue(uint32_t index, float value) override;
void d_setProgram(uint32_t index) ;
+ void d_setState(const char* key, const char* value) override;
// -------------------------------------------------------------------
// Process
@@ -146,8 +155,10 @@ protected:
private:
float attack,release,knee,ratio,thresdb,makeup[MAX_COMP],globalgain,stereodet;
- float gainr[MAX_COMP],toggle[MAX_COMP],listen[MAX_COMP],outl,outr,xover1,xover2;
+ float gainr[MAX_COMP],toggle[MAX_COMP],listen[MAX_COMP],maxL,maxR,outl,outr,xover1,xover2;
float old_yl[2][MAX_COMP], old_y1[2][MAX_COMP];
+ bool resetl;
+ bool resetr;
// Crossover filter coefficients
float a0[2][MAX_FILT];
float a1[2][MAX_FILT];
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
index fd5d86a..ef1e66f 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.cpp
@@ -202,6 +202,22 @@ ZaMultiCompX2UI::ZaMultiCompX2UI()
fToggleListen1->setStep(1.f);
fToggleListen1->setValue(0.f);
fToggleListen1->setCallback(this);
+
+ togglePosStart.setX(285.5);
+ togglePosEnd.setX(285.5);
+ togglePosStart.setY(254);
+ togglePosEnd.setY(254+11);
+
+ fToggleStereo = new ImageSlider(this, toggleImage);
+ fToggleStereo->setStartPos(togglePosStart);
+ fToggleStereo->setEndPos(togglePosEnd);
+ fToggleStereo->setRange(0.f,1.f);
+ fToggleStereo->setStep(1.f);
+ fToggleStereo->setValue(0.f);
+ fToggleStereo->setCallback(this);
+
+ fCanvasArea.setPos(530, 30);
+ fCanvasArea.setSize(110, 110);
}
ZaMultiCompX2UI::~ZaMultiCompX2UI()
@@ -223,6 +239,7 @@ ZaMultiCompX2UI::~ZaMultiCompX2UI()
delete fToggleListen1;
delete fToggleListen2;
delete fToggleListen3;
+ delete fToggleStereo;
}
// -----------------------------------------------------------------------
@@ -338,6 +355,11 @@ void ZaMultiCompX2UI::d_programChanged(uint32_t index)
fToggleListen1->setValue(0.0f);
fToggleListen2->setValue(0.0f);
fToggleListen3->setValue(0.0f);
+ fToggleStereo->setValue(0.0f);
+}
+
+void ZaMultiCompX2UI::d_stateChanged(const char*, const char*)
+{
}
// -----------------------------------------------------------------------
@@ -435,6 +457,8 @@ void ZaMultiCompX2UI::imageSliderDragStarted(ImageSlider* slider)
d_editParameter(ZaMultiCompX2Plugin::paramListen2, true);
else if (slider == fToggleListen3)
d_editParameter(ZaMultiCompX2Plugin::paramListen3, true);
+ else if (slider == fToggleStereo)
+ d_editParameter(ZaMultiCompX2Plugin::paramStereoDet, true);
}
void ZaMultiCompX2UI::imageSliderDragFinished(ImageSlider* slider)
@@ -451,13 +475,12 @@ void ZaMultiCompX2UI::imageSliderDragFinished(ImageSlider* slider)
d_editParameter(ZaMultiCompX2Plugin::paramListen2, false);
else if (slider == fToggleListen3)
d_editParameter(ZaMultiCompX2Plugin::paramListen3, false);
+ else if (slider == fToggleStereo)
+ d_editParameter(ZaMultiCompX2Plugin::paramStereoDet, false);
}
void ZaMultiCompX2UI::imageSliderValueChanged(ImageSlider* slider, float v)
{
- //float v = (value > 0.5) ? 1.f : 0.f;
- //slider->setValue(v);
-
if (slider == fToggleBypass1)
d_setParameterValue(ZaMultiCompX2Plugin::paramToggle1, v);
else if (slider == fToggleBypass2)
@@ -470,18 +493,22 @@ void ZaMultiCompX2UI::imageSliderValueChanged(ImageSlider* slider, float v)
d_setParameterValue(ZaMultiCompX2Plugin::paramListen2, 1.-v);
else if (slider == fToggleListen3)
d_setParameterValue(ZaMultiCompX2Plugin::paramListen3, 1.-v);
+ else if (slider == fToggleStereo)
+ d_setParameterValue(ZaMultiCompX2Plugin::paramStereoDet, v);
}
void ZaMultiCompX2UI::onDisplay()
{
fImgBackground.draw();
+ d_setState("stateMeterReset", "");
+
// draw leds
static const float sLedSpacing = 15.5f;
static const int sLedInitialX = 343;
- static const int sYellowLedStaticYL = 265;
- static const int sYellowLedStaticYR = 285;
+ static const int sYellowLedStaticYL = 254.5;
+ static const int sYellowLedStaticYR = 269.5;
static const int sRedLed1StaticY = 215;
static const int sRedLed2StaticY = 164;
static const int sRedLed3StaticY = 113;
@@ -678,6 +705,55 @@ void ZaMultiCompX2UI::onDisplay()
for (int i=0; i<numYellowLedsR; ++i)
fLedYellowImg.draw(sLedInitialX + i*sLedSpacing, sYellowLedStaticYR);
}
+/*
+// TESTING - remove later
+// this paints the 'fCanvasArea' so we can clearly see its bounds
+{
+const int x = fCanvasArea.getX();
+const int y = fCanvasArea.getY();
+const int w = fCanvasArea.getWidth();
+const int h = fCanvasArea.getHeight();
+
+glColor4f(0.0f, 1.0f, 0.0f, 0.9f);
+
+glBegin(GL_QUADS);
+glTexCoord2f(0.0f, 0.0f);
+glVertex2i(x, y);
+
+glTexCoord2f(1.0f, 0.0f);
+glVertex2i(x+w, y);
+
+glTexCoord2f(1.0f, 1.0f);
+glVertex2i(x+w, y+h);
+
+glTexCoord2f(0.0f, 1.0f);
+glVertex2i(x, y+h);
+glEnd();
+
+// reset color
+glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+}
+*/
+ float paramX = 0.5f;
+ float paramY = 0.5f;
+
+ // get x, y mapped to XY area
+ int x = fCanvasArea.getX() + paramX*fCanvasArea.getWidth();
+ int y = fCanvasArea.getY() + (1.f-paramY)*fCanvasArea.getHeight();
+
+ //draw lines, just for fun
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
+ glLineWidth(4);
+ glBegin(GL_LINES);
+ glVertex2i(x , y);
+ glVertex2i(x+15, y+25);
+ glEnd();
+
+ // reset color
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+
}
// -----------------------------------------------------------------------
diff --git a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.hpp b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.hpp
index b01b71f..810f56a 100644
--- a/plugins/ZaMultiCompX2/ZaMultiCompX2UI.hpp
+++ b/plugins/ZaMultiCompX2/ZaMultiCompX2UI.hpp
@@ -20,6 +20,7 @@
#include "DistrhoUI.hpp"
+#include "Geometry.hpp"
#include "ImageKnob.hpp"
#include "ImageSlider.hpp"
@@ -29,6 +30,7 @@
using DGL::Image;
using DGL::ImageKnob;
using DGL::ImageSlider;
+using DGL::Rectangle;
START_NAMESPACE_DISTRHO
@@ -61,6 +63,7 @@ protected:
void d_parameterChanged(uint32_t index, float value) override;
void d_programChanged(uint32_t index) override;
+ void d_stateChanged(const char*, const char*) override;
// -------------------------------------------------------------------
// Widget Callbacks
@@ -94,6 +97,7 @@ private:
ImageSlider* fToggleListen1;
ImageSlider* fToggleListen2;
ImageSlider* fToggleListen3;
+ ImageSlider* fToggleStereo;
Image fLedRedImg;
float fLedRedValue1;
@@ -102,6 +106,7 @@ private:
Image fLedYellowImg;
float fLedYellowValueL;
float fLedYellowValueR;
+ Rectangle<int> fCanvasArea;
};
// -----------------------------------------------------------------------