@@ -74,6 +74,7 @@ endif | |||
# DISTRHO plugins (Juice) | |||
OBJS += \ | |||
$(OBJDIR)/distrho-vectorjuice.cpp.o \ | |||
$(OBJDIR)/distrho-wobblejuice.cpp.o | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
@@ -215,6 +216,11 @@ $(OBJDIR)/distrho-prom.cpp.o: distrho-prom.cpp | |||
# ---------------------------------------------------------------------------------------------------------------------------- | |||
$(OBJDIR)/distrho-vectorjuice.cpp.o: distrho-vectorjuice.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_NAMESPACE=DISTRHO_VectorJuice -Idistrho-vectorjuice -I$(CWD)/modules/dgl -Wno-effc++ -c -o $@ | |||
$(OBJDIR)/distrho-wobblejuice.cpp.o: distrho-wobblejuice.cpp | |||
-@mkdir -p $(OBJDIR) | |||
@echo "Compiling $<" | |||
@@ -48,6 +48,7 @@ extern void carla_register_native_plugin_distrho_pingpongpan(void); | |||
extern void carla_register_native_plugin_distrho_prom(void); | |||
// DISTRHO plugins (Juice) | |||
extern void carla_register_native_plugin_distrho_vectorjuice(void); | |||
extern void carla_register_native_plugin_distrho_wobblejuice(void); | |||
// External-UI plugins | |||
@@ -103,6 +104,7 @@ void carla_register_all_native_plugins(void) | |||
#endif | |||
// DISTRHO plugins (Juice) | |||
carla_register_native_plugin_distrho_vectorjuice(); | |||
carla_register_native_plugin_distrho_wobblejuice(); | |||
#ifndef CARLA_OS_WIN | |||
@@ -499,6 +499,31 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = { | |||
/* copyright */ "GPL v2+", | |||
DESCFUNCS | |||
}, | |||
{ | |||
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | |||
#ifdef HAVE_DGL | |||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
|NATIVE_PLUGIN_HAS_UI | |||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||
|NATIVE_PLUGIN_USES_PARENT_ID | |||
|NATIVE_PLUGIN_USES_TIME), | |||
#else | |||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
|NATIVE_PLUGIN_USES_TIME), | |||
#endif | |||
/* supports */ static_cast<NativePluginSupports>(0x0), | |||
/* audioIns */ 8, | |||
/* audioOuts */ 2, | |||
/* midiIns */ 0, | |||
/* midiOuts */ 0, | |||
/* paramIns */ 13, | |||
/* paramOuts */ 4, | |||
/* name */ "VectorJuice", | |||
/* label */ "vectorjuice", | |||
/* maker */ "Andre Sklenar", | |||
/* copyright */ "GPL v2+", | |||
DESCFUNCS | |||
}, | |||
// ----------------------------------------------------------------------- | |||
// External-UI plugins | |||
@@ -0,0 +1,84 @@ | |||
/* | |||
* Carla Native Plugins | |||
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
// config fix | |||
#include "distrho-vectorjuice/DistrhoPluginInfo.h" | |||
#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) | |||
# undef DISTRHO_PLUGIN_HAS_UI | |||
# define DISTRHO_PLUGIN_HAS_UI 0 | |||
#endif | |||
// Plugin Code | |||
#include "distrho-vectorjuice/VectorJuicePlugin.cpp" | |||
#ifdef HAVE_DGL | |||
#include "distrho-vectorjuice/VectorJuiceArtwork.cpp" | |||
#include "distrho-vectorjuice/VectorJuiceUI.cpp" | |||
#endif | |||
// DISTRHO Code | |||
#define DISTRHO_PLUGIN_TARGET_CARLA | |||
#include "DistrhoPluginMain.cpp" | |||
#ifdef HAVE_DGL | |||
#include "DistrhoUIMain.cpp" | |||
#endif | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
static const NativePluginDescriptor vectorjuiceDesc = { | |||
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | |||
#ifdef HAVE_DGL | |||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
|NATIVE_PLUGIN_HAS_UI | |||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||
|NATIVE_PLUGIN_USES_PARENT_ID | |||
|NATIVE_PLUGIN_USES_TIME), | |||
#else | |||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||
|NATIVE_PLUGIN_USES_TIME), | |||
#endif | |||
/* supports */ static_cast<NativePluginSupports>(0x0), | |||
/* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | |||
/* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, | |||
/* midiIns */ 0, | |||
/* midiOuts */ 0, | |||
/* paramIns */ 13, | |||
/* paramOuts */ 4, | |||
/* name */ DISTRHO_PLUGIN_NAME, | |||
/* label */ "vectorjuice", | |||
/* maker */ "Andre Sklenar", | |||
/* copyright */ "GPL v2+", | |||
PluginDescriptorFILL(PluginCarla) | |||
}; | |||
END_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
CARLA_EXPORT | |||
void carla_register_native_plugin_distrho_vectorjuice(); | |||
CARLA_EXPORT | |||
void carla_register_native_plugin_distrho_vectorjuice() | |||
{ | |||
USE_NAMESPACE_DISTRHO | |||
carla_register_native_plugin(&vectorjuiceDesc); | |||
} | |||
// ----------------------------------------------------------------------- |
@@ -0,0 +1,36 @@ | |||
/* | |||
* Vector Juice Plugin | |||
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#ifndef DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
#define DISTRHO_PLUGIN_INFO_H_INCLUDED | |||
#define DISTRHO_PLUGIN_NAME "VectorJuice" | |||
#define DISTRHO_PLUGIN_HAS_UI 1 | |||
#define DISTRHO_PLUGIN_IS_SYNTH 0 | |||
#define DISTRHO_PLUGIN_NUM_INPUTS 8 | |||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | |||
#define DISTRHO_PLUGIN_WANT_LATENCY 0 | |||
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1 | |||
#define DISTRHO_PLUGIN_WANT_STATE 0 | |||
#define DISTRHO_PLUGIN_WANT_TIMEPOS 1 | |||
#define DISTRHO_PLUGIN_URI "urn:distrho:VectorJuice" | |||
#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED |
@@ -0,0 +1,55 @@ | |||
/* (Auto-generated binary data file). */ | |||
#ifndef BINARY_VECTORJUICEARTWORK_HPP | |||
#define BINARY_VECTORJUICEARTWORK_HPP | |||
namespace VectorJuiceArtwork | |||
{ | |||
extern const char* aboutData; | |||
const unsigned int aboutDataSize = 180000; | |||
const unsigned int aboutWidth = 300; | |||
const unsigned int aboutHeight = 200; | |||
extern const char* aboutButtonHoverData; | |||
const unsigned int aboutButtonHoverDataSize = 5888; | |||
const unsigned int aboutButtonHoverWidth = 92; | |||
const unsigned int aboutButtonHoverHeight = 16; | |||
extern const char* aboutButtonNormalData; | |||
const unsigned int aboutButtonNormalDataSize = 5888; | |||
const unsigned int aboutButtonNormalWidth = 92; | |||
const unsigned int aboutButtonNormalHeight = 16; | |||
extern const char* backgroundData; | |||
const unsigned int backgroundDataSize = 933432; | |||
const unsigned int backgroundWidth = 712; | |||
const unsigned int backgroundHeight = 437; | |||
extern const char* knobData; | |||
const unsigned int knobDataSize = 10404; | |||
const unsigned int knobWidth = 51; | |||
const unsigned int knobHeight = 51; | |||
extern const char* orbitData; | |||
const unsigned int orbitDataSize = 4096; | |||
const unsigned int orbitWidth = 32; | |||
const unsigned int orbitHeight = 32; | |||
extern const char* roundletData; | |||
const unsigned int roundletDataSize = 2500; | |||
const unsigned int roundletWidth = 25; | |||
const unsigned int roundletHeight = 25; | |||
extern const char* sliderData; | |||
const unsigned int sliderDataSize = 2600; | |||
const unsigned int sliderWidth = 26; | |||
const unsigned int sliderHeight = 25; | |||
extern const char* subOrbitData; | |||
const unsigned int subOrbitDataSize = 3364; | |||
const unsigned int subOrbitWidth = 29; | |||
const unsigned int subOrbitHeight = 29; | |||
} | |||
#endif // BINARY_VECTORJUICEARTWORK_HPP | |||
@@ -0,0 +1,391 @@ | |||
/* | |||
* Vector Juice Plugin | |||
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "VectorJuicePlugin.hpp" | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
VectorJuicePlugin::VectorJuicePlugin() | |||
: Plugin(paramCount, 1, 0) // 1 program, 0 states | |||
{ | |||
// set default values | |||
d_setProgram(0); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Init | |||
void VectorJuicePlugin::d_initParameter(uint32_t index, Parameter& parameter) | |||
{ | |||
switch (index) | |||
{ | |||
case paramX: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "X"; | |||
parameter.symbol = "x"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramY: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "Y"; | |||
parameter.symbol = "y"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramOrbitSizeX: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "Orbit Size X"; | |||
parameter.symbol = "sizex"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramOrbitSizeY: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "Orbit Size Y"; | |||
parameter.symbol = "sizey"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramOrbitSpeedX: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Speed X"; | |||
parameter.symbol = "speedx"; | |||
parameter.ranges.def = 4.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 128.0f; | |||
break; | |||
case paramOrbitSpeedY: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Speed Y"; | |||
parameter.symbol = "speedy"; | |||
parameter.ranges.def = 4.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 128.0f; | |||
break; | |||
case paramSubOrbitSize: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "SubOrbit Size"; | |||
parameter.symbol = "subsize"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramSubOrbitSpeed: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "SubOrbit Speed"; | |||
parameter.symbol = "subspeed"; | |||
parameter.ranges.def = 32.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 128.0f; | |||
break; | |||
case paramSubOrbitSmooth: | |||
parameter.hints = kParameterIsAutomable; | |||
parameter.name = "SubOrbit Wave"; | |||
parameter.symbol = "subwave"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramOrbitWaveX: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Wave X"; | |||
parameter.symbol = "wavex"; | |||
parameter.ranges.def = 3.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 4.0f; | |||
break; | |||
case paramOrbitWaveY: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Wave Y"; | |||
parameter.symbol = "wavey"; | |||
parameter.ranges.def = 3.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 4.0f; | |||
break; | |||
case paramOrbitPhaseX: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Phase X"; | |||
parameter.symbol = "phasex"; | |||
parameter.ranges.def = 1.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 4.0f; | |||
break; | |||
case paramOrbitPhaseY: | |||
parameter.hints = kParameterIsAutomable|kParameterIsInteger; | |||
parameter.name = "Orbit Phase Y"; | |||
parameter.symbol = "phasey"; | |||
parameter.ranges.def = 1.0f; | |||
parameter.ranges.min = 1.0f; | |||
parameter.ranges.max = 4.0f; | |||
break; | |||
case paramOrbitOutX: | |||
parameter.hints = kParameterIsOutput; | |||
parameter.name = "Orbit X"; | |||
parameter.symbol = "orx"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramOrbitOutY: | |||
parameter.hints = kParameterIsOutput; | |||
parameter.name = "Orbit Y"; | |||
parameter.symbol = "ory"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramSubOrbitOutX: | |||
parameter.hints = kParameterIsOutput; | |||
parameter.name = "SubOrbit X"; | |||
parameter.symbol = "sorx"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
case paramSubOrbitOutY: | |||
parameter.hints = kParameterIsOutput; | |||
parameter.name = "SubOrbit Y"; | |||
parameter.symbol = "sory"; | |||
parameter.ranges.def = 0.5f; | |||
parameter.ranges.min = 0.0f; | |||
parameter.ranges.max = 1.0f; | |||
break; | |||
} | |||
} | |||
void VectorJuicePlugin::d_initProgramName(uint32_t index, d_string& programName) | |||
{ | |||
if (index != 0) | |||
return; | |||
programName = "Default"; | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Internal data | |||
float VectorJuicePlugin::d_getParameterValue(uint32_t index) const | |||
{ | |||
switch (index) | |||
{ | |||
case paramX: | |||
return x; | |||
case paramY: | |||
return y; | |||
case paramOrbitSizeX: | |||
return orbitSizeX; | |||
case paramOrbitSizeY: | |||
return orbitSizeY; | |||
case paramOrbitSpeedX: | |||
return orbitSpeedX; | |||
case paramOrbitSpeedY: | |||
return orbitSpeedY; | |||
case paramSubOrbitSize: | |||
return subOrbitSize; | |||
case paramSubOrbitSpeed: | |||
return subOrbitSpeed; | |||
case paramSubOrbitSmooth: | |||
return subOrbitSmooth; | |||
case paramOrbitWaveX: | |||
return orbitWaveX; | |||
case paramOrbitWaveY: | |||
return orbitWaveY; | |||
case paramOrbitPhaseX: | |||
return orbitPhaseY; | |||
case paramOrbitPhaseY: | |||
return orbitPhaseY; | |||
case paramOrbitOutX: | |||
return orbitX; | |||
case paramOrbitOutY: | |||
return orbitY; | |||
case paramSubOrbitOutX: | |||
return subOrbitX; | |||
case paramSubOrbitOutY: | |||
return subOrbitY; | |||
default: | |||
return 0.0f; | |||
} | |||
} | |||
void VectorJuicePlugin::d_setParameterValue(uint32_t index, float value) | |||
{ | |||
bool resetPhase = false; | |||
switch (index) | |||
{ | |||
case paramX: | |||
x = value; | |||
break; | |||
case paramY: | |||
y = value; | |||
break; | |||
case paramOrbitSizeX: | |||
orbitSizeX = value; | |||
break; | |||
case paramOrbitSizeY: | |||
orbitSizeY = value; | |||
break; | |||
case paramOrbitSpeedX: | |||
orbitSpeedX = value; | |||
resetPhase = true; | |||
break; | |||
case paramOrbitSpeedY: | |||
orbitSpeedY = value; | |||
resetPhase = true; | |||
break; | |||
case paramSubOrbitSize: | |||
subOrbitSize = value; | |||
break; | |||
case paramSubOrbitSpeed: | |||
subOrbitSpeed = value; | |||
resetPhase = true; | |||
break; | |||
case paramSubOrbitSmooth: | |||
subOrbitSmooth = value; | |||
break; | |||
case paramOrbitWaveX: | |||
orbitWaveX = value; | |||
break; | |||
case paramOrbitWaveY: | |||
orbitWaveY = value; | |||
break; | |||
case paramOrbitPhaseX: | |||
orbitPhaseX = value; | |||
resetPhase = true; | |||
break; | |||
case paramOrbitPhaseY: | |||
orbitPhaseY = value; | |||
resetPhase = true; | |||
break; | |||
} | |||
if (resetPhase) | |||
{ | |||
sinePosX = 0; | |||
sinePosY = 0; | |||
sinePos = 0; | |||
} | |||
} | |||
void VectorJuicePlugin::d_setProgram(uint32_t index) | |||
{ | |||
if (index != 0) | |||
return; | |||
/* Default parameter values */ | |||
x = 0.5f; | |||
y = 0.5f; | |||
orbitSizeX = 0.5f; | |||
orbitSizeY = 0.5f; | |||
orbitSpeedX = 4.0f; | |||
orbitSpeedY = 4.0f; | |||
subOrbitSize = 0.5f; | |||
subOrbitSpeed = 32.0f; | |||
subOrbitSmooth = 0.5f; | |||
orbitWaveX = 3.0f; | |||
orbitWaveY = 3.0f; | |||
orbitPhaseX = 1.0f; | |||
orbitPhaseY = 1.0f; | |||
/* reset filter values */ | |||
d_activate(); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Process | |||
void VectorJuicePlugin::d_activate() | |||
{ | |||
/* Default variable values */ | |||
orbitX=orbitY=orbitTX=orbitTY=0.5; | |||
subOrbitX=subOrbitY=subOrbitTX=subOrbitTY=0; | |||
interpolationDivider=200; | |||
bar=tickX=tickY=percentageX=percentageY=tickOffsetX=0; | |||
tickOffsetY=sinePosX=sinePosY=tick=percentage=tickOffset=sinePos=0; | |||
waveBlend=0; | |||
//parameter smoothing | |||
for (int i=0; i<2; i++) { | |||
sA[i] = 0.99f; | |||
sB[i] = 1.f - sA[i]; | |||
sZ[i] = 0; | |||
} | |||
} | |||
void VectorJuicePlugin::d_run(const float** inputs, float** outputs, uint32_t frames) | |||
{ | |||
float out1, out2, tX, tY; | |||
for (uint32_t i=0; i<frames; i++) { | |||
//1.41421 -> 1 | |||
//<0 = 0 | |||
animate(); | |||
tX = subOrbitX; | |||
tY = subOrbitY; | |||
out1 = inputs[0][i]*tN(1-std::sqrt((tX*tX)+(tY*tY))); | |||
out2 = inputs[1][i]*tN(1-std::sqrt((tX*tX)+(tY*tY))); | |||
out1 += inputs[2][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+(tY*tY))); | |||
out2 += inputs[3][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+(tY*tY))); | |||
out1 += inputs[4][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+((1-tY)*(1-tY)))); | |||
out2 += inputs[5][i]*tN(1-std::sqrt(((1-tX)*(1-tX))+((1-tY)*(1-tY)))); | |||
out1 += inputs[6][i]*tN(1-std::sqrt((tX*tX)+((1-tY)*(1-tY)))); | |||
out2 += inputs[7][i]*tN(1-std::sqrt((tX*tX)+((1-tY)*(1-tY)))); | |||
outputs[0][i] = out1; | |||
outputs[1][i] = out2; | |||
} | |||
} | |||
// ----------------------------------------------------------------------- | |||
Plugin* createPlugin() | |||
{ | |||
return new VectorJuicePlugin(); | |||
} | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DISTRHO |
@@ -0,0 +1,236 @@ | |||
/* | |||
* Vector Juice Plugin | |||
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#ifndef VECTORJUICEPLUGIN_HPP_INCLUDED | |||
#define VECTORJUICEPLUGIN_HPP_INCLUDED | |||
#include "DistrhoPlugin.hpp" | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
class VectorJuicePlugin : public Plugin | |||
{ | |||
public: | |||
enum Parameters | |||
{ | |||
paramX = 0, | |||
paramY, | |||
paramOrbitSizeX, | |||
paramOrbitSizeY, | |||
paramOrbitSpeedX, | |||
paramOrbitSpeedY, | |||
paramSubOrbitSize, | |||
paramSubOrbitSpeed, | |||
paramSubOrbitSmooth, | |||
paramOrbitWaveX, | |||
paramOrbitWaveY, | |||
paramOrbitPhaseX, | |||
paramOrbitPhaseY, | |||
paramOrbitOutX, | |||
paramOrbitOutY, | |||
paramSubOrbitOutX, | |||
paramSubOrbitOutY, | |||
paramCount | |||
}; | |||
float smoothParameter(float in, int axis) { | |||
sZ[axis] = (in * sB[axis]) + (sZ[axis] * sA[axis]); | |||
return sZ[axis]; | |||
} | |||
float getSinePhase(float x) { | |||
return (-std::sin(x)); | |||
} | |||
float getSawPhase(float x) { | |||
return (-(2/M_PI *std::atan(1/std::tan(x/2)))); | |||
} | |||
float getRevSawPhase(float x) { | |||
return ((2/M_PI *std::atan(1/std::tan(x/2)))); | |||
} | |||
float getSquarePhase(float x) { | |||
return (std::round((std::sin(x)+1)/2)-0.5)*2; | |||
} | |||
//saw, sqr, sin, revSaw | |||
float getBlendedPhase(float x, float wave) | |||
{ | |||
//wave = 2; | |||
if (wave>=1 && wave<2) { | |||
/* saw vs sqr */ | |||
waveBlend = wave-1; | |||
return (getSawPhase(x)*(1-waveBlend) + getSquarePhase(x)*waveBlend); | |||
} else if (wave>=2 && wave<3) { | |||
/* sqr vs sin */ | |||
waveBlend = wave-2; | |||
return (getSquarePhase(x)*(1-waveBlend) + getSinePhase(x)*waveBlend); | |||
} else if (wave>=3 && wave<=4) { | |||
/* sin vs revSaw */ | |||
waveBlend = wave-3; | |||
return (getSinePhase(x)*(1-waveBlend) + getRevSawPhase(x)*waveBlend); | |||
} else { | |||
return 0.0f; | |||
} | |||
} | |||
float tN(float x) | |||
{ | |||
if (x>0) return x; | |||
else return 0; | |||
} | |||
void animate() | |||
{ | |||
//sync orbit with frame, bpm | |||
const TimePosition& time(d_getTimePosition()); | |||
bar = ((120.0/(time.bbt.valid ? time.bbt.beatsPerMinute : 120.0))*(d_getSampleRate())); | |||
int multiplier = 16;//2000*4; | |||
tickX = bar/(std::round(orbitSpeedX))*multiplier; | |||
tickY = bar/(std::round(orbitSpeedY))*multiplier; | |||
tick = bar/(std::round(subOrbitSpeed))*multiplier; | |||
if (time.playing) | |||
{ | |||
/* if rolling then sync to timepos */ | |||
tickOffsetX = time.frame-std::floor(time.frame/tickX)*tickX; | |||
tickOffsetY = time.frame-std::floor(time.frame/tickY)*tickY; | |||
tickOffset = time.frame-std::floor(time.frame/tick)*tick; | |||
percentageX = tickOffsetX/tickX; | |||
percentageY = tickOffsetY/tickY; | |||
percentage = tickOffset/tick; | |||
sinePosX = (M_PI*2)*percentageX; | |||
sinePosY = (M_PI*2)*percentageY; | |||
sinePos = (M_PI*2)*percentage; | |||
} else { | |||
/* else just keep on wobblin' */ | |||
sinePosX += (2*M_PI)/(tickX); | |||
sinePosY += (2*M_PI)/(tickY); | |||
sinePos += (M_PI)/(tick); | |||
if (sinePosX>2*M_PI) { | |||
sinePosX = 0; | |||
} | |||
if (sinePosY>2*M_PI) { | |||
sinePosY = 0; | |||
} | |||
if (sinePos>2*M_PI) { | |||
sinePos = 0; | |||
} | |||
} | |||
//0..1 | |||
//0..3 | |||
//0, 1, 2, 3 | |||
//* 0.25 | |||
//0, 0.25, 0.5, 0.75 | |||
float tempPhaseX = std::round(orbitPhaseX)*0.25-0.25; | |||
float tempPhaseY = std::round(orbitPhaseY)*0.25-0.25; | |||
orbitX = x+getBlendedPhase(sinePosX + tempPhaseX*(2*M_PI), std::round(orbitWaveX))*(orbitSizeX/2); | |||
orbitY = y+getBlendedPhase(sinePosY+M_PI/2 + tempPhaseY*(2*M_PI), std::round(orbitWaveY))*(orbitSizeY/2); | |||
subOrbitX = smoothParameter(orbitX+getBlendedPhase(sinePos, 3)*(subOrbitSize/3), 0); | |||
subOrbitY = smoothParameter(orbitY+getBlendedPhase(sinePos+M_PI/2, 3)*(subOrbitSize/3), 1); | |||
if (orbitX<0) orbitX=0; | |||
if (orbitX>1) orbitX=1; | |||
if (orbitY<0) orbitY=0; | |||
if (orbitY>1) orbitY=1; | |||
if (subOrbitX<0) subOrbitX=0; | |||
if (subOrbitX>1) subOrbitX=1; | |||
if (subOrbitY<0) subOrbitY=0; | |||
if (subOrbitY>1) subOrbitY=1; | |||
} | |||
VectorJuicePlugin(); | |||
protected: | |||
// ------------------------------------------------------------------- | |||
// Information | |||
const char* d_getLabel() const noexcept override | |||
{ | |||
return "VectorJuice"; | |||
} | |||
const char* d_getMaker() const noexcept override | |||
{ | |||
return "Andre Sklenar"; | |||
} | |||
const char* d_getLicense() const noexcept override | |||
{ | |||
return "GPL v2+"; | |||
} | |||
uint32_t d_getVersion() const noexcept override | |||
{ | |||
return 0x1000; | |||
} | |||
long d_getUniqueId() const noexcept override | |||
{ | |||
return d_cconst('V', 'e', 'c', 'J'); | |||
} | |||
// ------------------------------------------------------------------- | |||
// Init | |||
void d_initParameter(uint32_t index, Parameter& parameter) override; | |||
void d_initProgramName(uint32_t index, d_string& programName) override; | |||
// ------------------------------------------------------------------- | |||
// Internal data | |||
float d_getParameterValue(uint32_t index) const override; | |||
void d_setParameterValue(uint32_t index, float value) override; | |||
void d_setProgram(uint32_t index) override; | |||
// ------------------------------------------------------------------- | |||
// Process | |||
void d_activate() override; | |||
void d_run(const float** inputs, float** outputs, uint32_t frames) override; | |||
// ------------------------------------------------------------------- | |||
private: | |||
float x, y; | |||
float orbitX, orbitY; | |||
float orbitTX, orbitTY; //targetX and targetY for interpolation | |||
float subOrbitX, subOrbitY; | |||
float subOrbitTX, subOrbitTY; | |||
float subOrbitSpeed, subOrbitSize, orbitSpeedX, orbitSpeedY; | |||
float orbitSizeX, orbitSizeY; | |||
float interpolationDivider; | |||
float bar, tickX, tickY, percentageX, percentageY, tickOffsetX, tickOffsetY; | |||
float sinePosX, sinePosY, tick, percentage, tickOffset, sinePos; | |||
float orbitWaveX, orbitWaveY, subOrbitSmooth, waveBlend; | |||
float orbitPhaseX, orbitPhaseY; | |||
//parameter smoothing, for subOrbitX and subOrbitY | |||
float sA[2], sB[2], sZ[2]; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DISTRHO | |||
#endif // VECTORJUICE_HPP_INCLUDED |
@@ -0,0 +1,461 @@ | |||
/* | |||
* Vector Juice Plugin | |||
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#include "VectorJuicePlugin.hpp" | |||
#include "VectorJuiceUI.hpp" | |||
using DGL::Point; | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
VectorJuiceUI::VectorJuiceUI() | |||
: UI(), | |||
fAboutWindow(this) | |||
{ | |||
setSize(VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight); | |||
// xy params | |||
paramX = paramY = 0.5f; | |||
// orbit params | |||
orbitX = orbitY = subOrbitX = subOrbitY = 0.5f; | |||
// set the XY canvas area | |||
fDragging = false; | |||
fDragValid = false; | |||
fLastX = fLastY = 0; | |||
fCanvasArea.setPos(22+12, 49+12); | |||
fCanvasArea.setSize(368-24, 368-24); | |||
// background | |||
fImgBackground = Image(VectorJuiceArtwork::backgroundData, VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight, GL_BGR); | |||
//roundlet | |||
fImgRoundlet = Image(VectorJuiceArtwork::roundletData, VectorJuiceArtwork::roundletWidth, VectorJuiceArtwork::roundletHeight); | |||
//orbit | |||
fImgOrbit = Image(VectorJuiceArtwork::orbitData, VectorJuiceArtwork::orbitWidth, VectorJuiceArtwork::orbitHeight); | |||
//subOrbit | |||
fImgSubOrbit = Image(VectorJuiceArtwork::subOrbitData, VectorJuiceArtwork::subOrbitWidth, VectorJuiceArtwork::subOrbitHeight); | |||
// about | |||
Image aboutImage(VectorJuiceArtwork::aboutData, VectorJuiceArtwork::aboutWidth, VectorJuiceArtwork::aboutHeight, GL_BGR); | |||
fAboutWindow.setImage(aboutImage); | |||
// about button | |||
Image aboutImageNormal(VectorJuiceArtwork::aboutButtonNormalData, VectorJuiceArtwork::aboutButtonNormalWidth, VectorJuiceArtwork::aboutButtonNormalHeight); | |||
Image aboutImageHover(VectorJuiceArtwork::aboutButtonHoverData, VectorJuiceArtwork::aboutButtonHoverWidth, VectorJuiceArtwork::aboutButtonHoverHeight); | |||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | |||
fButtonAbout->setAbsolutePos(599, 17); | |||
fButtonAbout->setCallback(this); | |||
// knobs | |||
Image knobImage(VectorJuiceArtwork::knobData, VectorJuiceArtwork::knobWidth, VectorJuiceArtwork::knobHeight); | |||
// knob KnobOrbitSizeX | |||
fKnobOrbitSizeX = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobOrbitSizeX->setId(VectorJuicePlugin::paramOrbitSizeX); | |||
fKnobOrbitSizeX->setAbsolutePos(423, 73); | |||
fKnobOrbitSizeX->setRotationAngle(270); | |||
fKnobOrbitSizeX->setRange(0.0f, 1.0f); | |||
fKnobOrbitSizeX->setDefault(0.5f); | |||
fKnobOrbitSizeX->setCallback(this); | |||
// knob KnobOrbitSizeY | |||
fKnobOrbitSizeY = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobOrbitSizeY->setId(VectorJuicePlugin::paramOrbitSizeY); | |||
fKnobOrbitSizeY->setAbsolutePos(516, 73); | |||
fKnobOrbitSizeY->setRotationAngle(270); | |||
fKnobOrbitSizeY->setRange(0.0f, 1.0f); | |||
fKnobOrbitSizeY->setDefault(0.5f); | |||
fKnobOrbitSizeY->setCallback(this); | |||
// knob KnobOrbitSpeedX | |||
fKnobOrbitSpeedX = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobOrbitSpeedX->setId(VectorJuicePlugin::paramOrbitSpeedX); | |||
fKnobOrbitSpeedX->setAbsolutePos(423, 185); | |||
fKnobOrbitSpeedX->setRotationAngle(270); | |||
fKnobOrbitSpeedX->setStep(1.0f); | |||
fKnobOrbitSpeedX->setRange(1.0f, 128.0f); | |||
fKnobOrbitSpeedX->setDefault(4.0f); | |||
fKnobOrbitSpeedX->setCallback(this); | |||
// knob KnobOrbitSpeedY | |||
fKnobOrbitSpeedY = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobOrbitSpeedY->setId(VectorJuicePlugin::paramOrbitSpeedY); | |||
fKnobOrbitSpeedY->setAbsolutePos(516, 185); | |||
fKnobOrbitSpeedY->setRotationAngle(270); | |||
fKnobOrbitSpeedY->setStep(1.0f); | |||
fKnobOrbitSpeedY->setRange(1.0f, 128.0f); | |||
fKnobOrbitSpeedY->setDefault(4.0f); | |||
fKnobOrbitSpeedY->setCallback(this); | |||
// knob KnobSubOrbitSize | |||
fKnobSubOrbitSize = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobSubOrbitSize->setId(VectorJuicePlugin::paramSubOrbitSize); | |||
fKnobSubOrbitSize->setAbsolutePos(620, 73); | |||
fKnobSubOrbitSize->setRange(0.0f, 1.0f); | |||
fKnobSubOrbitSize->setRotationAngle(270); | |||
fKnobSubOrbitSize->setDefault(0.5f); | |||
fKnobSubOrbitSize->setCallback(this); | |||
// knob KnobSubOrbitSpeed | |||
fKnobSubOrbitSpeed = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobSubOrbitSpeed->setId(VectorJuicePlugin::paramSubOrbitSpeed); | |||
fKnobSubOrbitSpeed->setAbsolutePos(620, 185); | |||
fKnobSubOrbitSpeed->setRotationAngle(270); | |||
fKnobSubOrbitSpeed->setStep(1.0f); | |||
fKnobSubOrbitSpeed->setRange(1.0f, 128.0f); | |||
fKnobSubOrbitSpeed->setDefault(32.0f); | |||
fKnobSubOrbitSpeed->setCallback(this); | |||
// knob KnobSubOrbitSmooth | |||
fKnobSubOrbitSmooth = new ImageKnob(this, knobImage, ImageKnob::Vertical); | |||
fKnobSubOrbitSmooth->setId(VectorJuicePlugin::paramSubOrbitSmooth); | |||
fKnobSubOrbitSmooth->setAbsolutePos(620, 297); | |||
fKnobSubOrbitSmooth->setRotationAngle(270); | |||
fKnobSubOrbitSmooth->setRange(0.0f, 1.0f); | |||
fKnobSubOrbitSmooth->setDefault(0.5f); | |||
fKnobSubOrbitSmooth->setCallback(this); | |||
// sliders | |||
Image sliderImage(VectorJuiceArtwork::sliderData, VectorJuiceArtwork::sliderWidth, VectorJuiceArtwork::sliderHeight); | |||
Point<int> sliderPosStart(410, 284); | |||
Point<int> sliderPosEnd(410+48, 284); | |||
// slider OrbitWaveX | |||
fSliderOrbitWaveX = new ImageSlider(this, sliderImage); | |||
fSliderOrbitWaveX->setId(VectorJuicePlugin::paramOrbitWaveX); | |||
fSliderOrbitWaveX->setStartPos(sliderPosStart); | |||
fSliderOrbitWaveX->setEndPos(sliderPosEnd); | |||
fSliderOrbitWaveX->setRange(1.0f, 4.0f); | |||
fSliderOrbitWaveX->setStep(1.0f); | |||
fSliderOrbitWaveX->setCallback(this); | |||
// slider OrbitWaveY | |||
sliderPosStart.setX(503); | |||
sliderPosEnd.setX(503+48); | |||
fSliderOrbitWaveY = new ImageSlider(this, sliderImage); | |||
fSliderOrbitWaveY->setId(VectorJuicePlugin::paramOrbitWaveY); | |||
fSliderOrbitWaveY->setStartPos(sliderPosStart); | |||
fSliderOrbitWaveY->setEndPos(sliderPosEnd); | |||
fSliderOrbitWaveY->setRange(1.0f, 4.0f); | |||
fSliderOrbitWaveY->setStep(1.0f); | |||
fSliderOrbitWaveY->setCallback(this); | |||
// slider OrbitPhaseX | |||
sliderPosStart.setX(410); | |||
sliderPosStart.setY(345); | |||
sliderPosEnd.setX(410+48); | |||
sliderPosEnd.setY(345); | |||
fSliderOrbitPhaseX = new ImageSlider(this, sliderImage); | |||
fSliderOrbitPhaseX->setId(VectorJuicePlugin::paramOrbitPhaseX); | |||
fSliderOrbitPhaseX->setStartPos(sliderPosStart); | |||
fSliderOrbitPhaseX->setEndPos(sliderPosEnd); | |||
fSliderOrbitPhaseX->setRange(1.0f, 4.0f); | |||
fSliderOrbitPhaseX->setStep(1.0f); | |||
fSliderOrbitPhaseX->setCallback(this); | |||
// slider OrbitPhaseY | |||
sliderPosStart.setX(503); | |||
sliderPosEnd.setX(503+48); | |||
fSliderOrbitPhaseY = new ImageSlider(this, sliderImage); | |||
fSliderOrbitPhaseY->setId(VectorJuicePlugin::paramOrbitPhaseY); | |||
fSliderOrbitPhaseY->setStartPos(sliderPosStart); | |||
fSliderOrbitPhaseY->setEndPos(sliderPosEnd); | |||
fSliderOrbitPhaseY->setRange(1.0f, 4.0f); | |||
fSliderOrbitPhaseY->setStep(1.0f); | |||
fSliderOrbitPhaseY->setCallback(this); | |||
// set default values | |||
d_programChanged(0); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// DSP Callbacks | |||
void VectorJuiceUI::d_parameterChanged(uint32_t index, float value) | |||
{ | |||
switch (index) | |||
{ | |||
case VectorJuicePlugin::paramX: | |||
if (paramX != value) | |||
{ | |||
paramX = value; | |||
fDragValid = false; | |||
repaint(); | |||
} | |||
break; | |||
case VectorJuicePlugin::paramY: | |||
if (paramY != value) | |||
{ | |||
paramY = value; | |||
fDragValid = false; | |||
repaint(); | |||
} | |||
break; | |||
case VectorJuicePlugin::paramOrbitSizeX: | |||
fKnobOrbitSizeX->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitSizeY: | |||
fKnobOrbitSizeY->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitSpeedX: | |||
fKnobOrbitSpeedX->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitSpeedY: | |||
fKnobOrbitSpeedY->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramSubOrbitSize: | |||
fKnobSubOrbitSize->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramSubOrbitSpeed: | |||
fKnobSubOrbitSpeed->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramSubOrbitSmooth: | |||
fKnobSubOrbitSmooth->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitWaveX: | |||
fSliderOrbitWaveX->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitWaveY: | |||
fSliderOrbitWaveY->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitPhaseX: | |||
fSliderOrbitPhaseX->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitPhaseY: | |||
fSliderOrbitPhaseY->setValue(value); | |||
break; | |||
case VectorJuicePlugin::paramOrbitOutX: | |||
if (orbitX != value) | |||
{ | |||
orbitX = value; | |||
repaint(); | |||
} | |||
break; | |||
case VectorJuicePlugin::paramOrbitOutY: | |||
if (orbitY != value) | |||
{ | |||
orbitY = value; | |||
repaint(); | |||
} | |||
break; | |||
case VectorJuicePlugin::paramSubOrbitOutX: | |||
if (subOrbitX != value) | |||
{ | |||
subOrbitX = value; | |||
repaint(); | |||
} | |||
break; | |||
case VectorJuicePlugin::paramSubOrbitOutY: | |||
if (subOrbitY != value) | |||
{ | |||
subOrbitY = value; | |||
repaint(); | |||
} | |||
break; | |||
} | |||
} | |||
void VectorJuiceUI::d_programChanged(uint32_t index) | |||
{ | |||
if (index != 0) | |||
return; | |||
// Default values | |||
paramX = paramY = 0.5f; | |||
fKnobOrbitSizeX->setValue(0.5f); | |||
fKnobOrbitSizeY->setValue(0.5f); | |||
fKnobOrbitSpeedX->setValue(4.0f); | |||
fKnobOrbitSpeedY->setValue(4.0f); | |||
fKnobSubOrbitSize->setValue(0.5f); | |||
fKnobSubOrbitSpeed->setValue(32.0f); | |||
fKnobSubOrbitSmooth->setValue(0.5f); | |||
fSliderOrbitWaveX->setValue(3.0f); | |||
fSliderOrbitWaveY->setValue(3.0f); | |||
fSliderOrbitPhaseX->setValue(1.0f); | |||
fSliderOrbitPhaseY->setValue(1.0f); | |||
} | |||
// ----------------------------------------------------------------------- | |||
// Widget Callbacks | |||
void VectorJuiceUI::imageButtonClicked(ImageButton* button, int) | |||
{ | |||
if (button != fButtonAbout) | |||
return; | |||
fAboutWindow.exec(); | |||
} | |||
void VectorJuiceUI::imageKnobDragStarted(ImageKnob* knob) | |||
{ | |||
d_editParameter(knob->getId(), true); | |||
} | |||
void VectorJuiceUI::imageKnobDragFinished(ImageKnob* knob) | |||
{ | |||
d_editParameter(knob->getId(), false); | |||
} | |||
void VectorJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value) | |||
{ | |||
d_setParameterValue(knob->getId(), value); | |||
} | |||
void VectorJuiceUI::imageSliderDragStarted(ImageSlider* slider) | |||
{ | |||
d_editParameter(slider->getId(), true); | |||
} | |||
void VectorJuiceUI::imageSliderDragFinished(ImageSlider* slider) | |||
{ | |||
d_editParameter(slider->getId(), false); | |||
} | |||
void VectorJuiceUI::imageSliderValueChanged(ImageSlider* slider, float value) | |||
{ | |||
d_setParameterValue(slider->getId(), value); | |||
} | |||
void VectorJuiceUI::onDisplay() | |||
{ | |||
fImgBackground.draw(); | |||
// get x, y mapped to XY area | |||
int x = fCanvasArea.getX() + paramX*fCanvasArea.getWidth() - fImgRoundlet.getWidth()/2; | |||
int y = fCanvasArea.getY() + paramY*fCanvasArea.getHeight() - fImgRoundlet.getHeight()/2; | |||
int nOrbitX = fCanvasArea.getX()+((orbitX)*fCanvasArea.getWidth())-15; | |||
int nOrbitY = fCanvasArea.getY()+((orbitY)*fCanvasArea.getWidth())-15; | |||
int nSubOrbitX = fCanvasArea.getX()+(subOrbitX*fCanvasArea.getWidth())-15; | |||
int nSubOrbitY = fCanvasArea.getY()+(subOrbitY*fCanvasArea.getWidth())-14; | |||
//draw lines, just for fun | |||
glEnable(GL_BLEND); | |||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |||
glColor4f(0.0f, 1.0f, 0.0f, 0.05f); | |||
glLineWidth(4); | |||
glBegin(GL_LINES); | |||
glVertex2i(x+ fImgRoundlet.getWidth()/2, y+ fImgRoundlet.getHeight()/2); | |||
glVertex2i(nOrbitX+15, nOrbitY+15); | |||
glEnd(); | |||
glBegin(GL_LINES); | |||
glVertex2i(nOrbitX+15, nOrbitY+15); | |||
glVertex2i(nSubOrbitX+15, nSubOrbitY+14); | |||
glEnd(); | |||
// reset color | |||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |||
// draw roundlet and orbits | |||
fImgRoundlet.drawAt(x, y); | |||
fImgOrbit.drawAt(nOrbitX, nOrbitY); | |||
fImgSubOrbit.drawAt(nSubOrbitX, nSubOrbitY); | |||
} | |||
bool VectorJuiceUI::onMouse(const MouseEvent& ev) | |||
{ | |||
if (ev.button != 1) | |||
return false; | |||
if (ev.press) | |||
{ | |||
if (! fCanvasArea.contains(ev.pos)) | |||
return false; | |||
fDragging = true; | |||
fDragValid = true; | |||
fLastX = ev.pos.getX(); | |||
fLastY = ev.pos.getY(); | |||
return true; | |||
} | |||
else if (fDragging) | |||
{ | |||
fDragging = false; | |||
return true; | |||
} | |||
return false; | |||
} | |||
bool VectorJuiceUI::onMotion(const MotionEvent& ev) | |||
{ | |||
if (! fDragging) | |||
return false; | |||
const int x = ev.pos.getX(); | |||
const int y = ev.pos.getY(); | |||
if (! fDragValid) | |||
{ | |||
fDragValid = true; | |||
fLastX = x; | |||
fLastY = y; | |||
} | |||
const int movedX = fLastX - x; | |||
const int movedY = fLastY - y; | |||
fLastX = x; | |||
fLastY = y; | |||
float newX = paramX; | |||
float newY = paramY; | |||
newX -= float(movedX)/fCanvasArea.getWidth(); | |||
newY -= float(movedY)/fCanvasArea.getHeight(); | |||
if (newX < 0.0f) | |||
newX = 0.0f; | |||
else if (newX > 1.0f) | |||
newX = 1.0f; | |||
if (newY < 0.0f) | |||
newY = 0.0f; | |||
else if (newY > 1.0f) | |||
newY = 1.0f; | |||
if (newX != paramX) | |||
{ | |||
paramX = newX; | |||
d_setParameterValue(VectorJuicePlugin::paramX, paramX); | |||
repaint(); | |||
} | |||
if (newY != paramY) | |||
{ | |||
paramY = newY; | |||
d_setParameterValue(VectorJuicePlugin::paramY, paramY); | |||
repaint(); | |||
} | |||
return true; | |||
} | |||
// ----------------------------------------------------------------------- | |||
UI* createUI() | |||
{ | |||
return new VectorJuiceUI(); | |||
} | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DISTRHO |
@@ -0,0 +1,102 @@ | |||
/* | |||
* Vector Juice Plugin | |||
* Copyright (C) 2014 Andre Sklenar <andre.sklenar@gmail.com>, www.juicelab.cz | |||
* | |||
* This program is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU General Public License as | |||
* published by the Free Software Foundation; either version 2 of | |||
* the License, or any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* For a full copy of the GNU General Public License see the doc/GPL.txt file. | |||
*/ | |||
#ifndef VECTORJUICEUI_HPP_INCLUDED | |||
#define VECTORJUICEUI_HPP_INCLUDED | |||
#include "DistrhoUI.hpp" | |||
#include "ImageAboutWindow.hpp" | |||
#include "ImageButton.hpp" | |||
#include "ImageKnob.hpp" | |||
#include "ImageSlider.hpp" | |||
#include "VectorJuiceArtwork.hpp" | |||
using DGL::Image; | |||
using DGL::ImageAboutWindow; | |||
using DGL::ImageButton; | |||
using DGL::ImageKnob; | |||
using DGL::ImageSlider; | |||
START_NAMESPACE_DISTRHO | |||
// ----------------------------------------------------------------------- | |||
class VectorJuiceUI : public UI, | |||
public ImageButton::Callback, | |||
public ImageKnob::Callback, | |||
public ImageSlider::Callback | |||
{ | |||
public: | |||
VectorJuiceUI(); | |||
protected: | |||
// ------------------------------------------------------------------- | |||
// DSP Callbacks | |||
void d_parameterChanged(uint32_t index, float value) override; | |||
void d_programChanged(uint32_t index) override; | |||
// ------------------------------------------------------------------- | |||
// Widget Callbacks | |||
void imageButtonClicked(ImageButton* button, int) override; | |||
void imageKnobDragStarted(ImageKnob* knob) override; | |||
void imageKnobDragFinished(ImageKnob* knob) override; | |||
void imageKnobValueChanged(ImageKnob* knob, float value) override; | |||
void imageSliderDragStarted(ImageSlider* slider) override; | |||
void imageSliderDragFinished(ImageSlider* slider) override; | |||
void imageSliderValueChanged(ImageSlider* slider, float value) override; | |||
void onDisplay() override; | |||
bool onMouse(const MouseEvent&) override; | |||
bool onMotion(const MotionEvent&) override; | |||
private: | |||
float paramX, paramY; | |||
Image fImgBackground; | |||
Image fImgRoundlet; | |||
Image fImgOrbit; | |||
Image fImgSubOrbit; | |||
ImageAboutWindow fAboutWindow; | |||
ScopedPointer<ImageButton> fButtonAbout; | |||
//knobs | |||
ScopedPointer<ImageKnob> fKnobOrbitSpeedX, fKnobOrbitSpeedY, fKnobOrbitSizeX, fKnobOrbitSizeY; | |||
ScopedPointer<ImageKnob> fKnobSubOrbitSpeed, fKnobSubOrbitSize, fKnobSubOrbitSmooth; | |||
//sliders | |||
ScopedPointer<ImageSlider> fSliderOrbitWaveX, fSliderOrbitWaveY; | |||
ScopedPointer<ImageSlider> fSliderOrbitPhaseX, fSliderOrbitPhaseY; | |||
// needed for XY canvas handling | |||
bool fDragging; | |||
bool fDragValid; | |||
int fLastX; | |||
int fLastY; | |||
DGL::Rectangle<int> fCanvasArea; | |||
float orbitX, orbitY, subOrbitX, subOrbitY; | |||
}; | |||
// ----------------------------------------------------------------------- | |||
END_NAMESPACE_DISTRHO | |||
#endif // VECTORJUICEUI_HPP_INCLUDED |
@@ -72,7 +72,7 @@ struct PluginListManager { | |||
std::strcmp(desc->label, "nekobi" ) == 0 || | |||
std::strcmp(desc->label, "pingpongpan" ) == 0 || | |||
std::strcmp(desc->label, "prom" ) == 0 || | |||
std::strstr(desc->label, "Juice" ) != nullptr || | |||
std::strstr(desc->label, "juice" ) != nullptr || | |||
std::strstr(desc->label, "Zam" ) != nullptr) | |||
{ | |||
continue; | |||