diff --git a/source/native-plugins/Makefile b/source/native-plugins/Makefile index 01b062d31..cf0e48d97 100644 --- a/source/native-plugins/Makefile +++ b/source/native-plugins/Makefile @@ -47,7 +47,8 @@ OBJS = \ $(OBJDIR)/bigmeter.cpp.o \ $(OBJDIR)/midi-file.cpp.o \ $(OBJDIR)/midi-pattern.cpp.o \ - $(OBJDIR)/notes.cpp.o + $(OBJDIR)/notes.cpp.o \ + $(OBJDIR)/xycontroller.cpp.o OBJS_audiogain = \ $(OBJDIR)/audio-gain.c.o diff --git a/source/native-plugins/_all.c b/source/native-plugins/_all.c index bb9407144..955f2daed 100644 --- a/source/native-plugins/_all.c +++ b/source/native-plugins/_all.c @@ -48,6 +48,7 @@ extern void carla_register_native_plugin_carla(void); // External-UI plugins extern void carla_register_native_plugin_bigmeter(void); extern void carla_register_native_plugin_notes(void); +extern void carla_register_native_plugin_xycontroller(void); #ifdef HAVE_EXTERNAL_PLUGINS void carla_register_all_native_external_plugins(void); @@ -88,6 +89,7 @@ void carla_register_all_native_plugins(void) carla_register_native_plugin_bigmeter(); carla_register_native_plugin_midipattern(); carla_register_native_plugin_notes(); + carla_register_native_plugin_xycontroller(); #endif // HAVE_PYQT #ifdef HAVE_EXTERNAL_PLUGINS diff --git a/source/native-plugins/_data.cpp b/source/native-plugins/_data.cpp index e84b40652..5970d2570 100644 --- a/source/native-plugins/_data.cpp +++ b/source/native-plugins/_data.cpp @@ -556,6 +556,23 @@ static const NativePluginDescriptor sNativePluginDescriptors[] = { /* copyright */ "GNU GPL v2+", DESCFUNCS_WITHOUTCV }, +{ + /* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, + /* hints */ static_cast(NATIVE_PLUGIN_IS_RTSAFE + |NATIVE_PLUGIN_HAS_UI), + /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, + /* audioIns */ 0, + /* audioOuts */ 0, + /* midiIns */ 0, + /* midiOuts */ 1, + /* paramIns */ 2, + /* paramOuts */ 2, + /* name */ "XY Controller", + /* label */ "xycontroller", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + DESCFUNCS_WITHOUTCV +} #endif #ifdef HAVE_EXTERNAL_PLUGINS diff --git a/source/native-plugins/xycontroller.cpp b/source/native-plugins/xycontroller.cpp new file mode 100644 index 000000000..cc6cee44a --- /dev/null +++ b/source/native-plugins/xycontroller.cpp @@ -0,0 +1,162 @@ +/* + * XY Controller UI, taken from Cadence + * Copyright (C) 2011-2020 Filipe Coelho + * + * 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 "CarlaDefines.h" + +#include "CarlaNativeExtUI.hpp" + +// ----------------------------------------------------------------------- + +class XYControllerPlugin : public NativePluginAndUiClass +{ +public: + enum Parameters { + kParamInX, + kParamInY, + kParamOutX, + kParamOutY, + kParamCount, + }; + + XYControllerPlugin(const NativeHostDescriptor* const host) + : NativePluginAndUiClass(host, "xycontroller-ui"), + fParams() + { + carla_fill(fParams, 50.0f, kParamCount); + } + +protected: + // ------------------------------------------------------------------- + // Plugin parameter calls + + uint32_t getParameterCount() const override + { + return kParamCount; + } + + const NativeParameter* getParameterInfo(const uint32_t index) const override + { + CARLA_SAFE_ASSERT_RETURN(index < kParamCount, nullptr); + + static NativeParameter param; + + int hints = NATIVE_PARAMETER_IS_ENABLED|NATIVE_PARAMETER_IS_AUTOMABLE; + + param.name = nullptr; + param.unit = "%"; + param.ranges.def = 50.0f; + param.ranges.min = 0.0f; + param.ranges.max = 100.0f; + param.ranges.step = 1.0f; + param.ranges.stepSmall = 0.01f; + param.ranges.stepLarge = 10.0f; + param.scalePointCount = 0; + param.scalePoints = nullptr; + + switch (index) + { + case kParamInX: + param.name = "X"; + break; + case kParamInY: + param.name = "Y"; + break; + case kParamOutX: + hints |= NATIVE_PARAMETER_IS_OUTPUT; + param.name = "Out X"; + break; + case kParamOutY: + hints |= NATIVE_PARAMETER_IS_OUTPUT; + param.name = "Out Y"; + break; + } + + param.hints = static_cast(hints); + + return ¶m; + } + + float getParameterValue(const uint32_t index) const override + { + CARLA_SAFE_ASSERT_RETURN(index < kParamCount, 0.0f); + + return fParams[index]; + } + + // ------------------------------------------------------------------- + // Plugin state calls + + void setParameterValue(const uint32_t index, const float value) override + { + switch (index) + { + case kParamInX: + case kParamInY: + fParams[index] = value; + break; + } + } + + // ------------------------------------------------------------------- + // Plugin process calls + + void process(const float* const*, float**, const uint32_t, + const NativeMidiEvent* const, const uint32_t) override + { + fParams[kParamOutX] = fParams[kParamInX]; + fParams[kParamOutY] = fParams[kParamInY]; + } + +private: + float fParams[kParamCount]; + + PluginClassEND(XYControllerPlugin) + CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(XYControllerPlugin) +}; + +// ----------------------------------------------------------------------- + +static const NativePluginDescriptor notesDesc = { + /* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, + /* hints */ static_cast(NATIVE_PLUGIN_IS_RTSAFE + |NATIVE_PLUGIN_HAS_UI), + /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, + /* audioIns */ 0, + /* audioOuts */ 0, + /* midiIns */ 0, + /* midiOuts */ 1, + /* paramIns */ 2, + /* paramOuts */ 2, + /* name */ "XY Controller", + /* label */ "xycontroller", + /* maker */ "falkTX", + /* copyright */ "GNU GPL v2+", + PluginDescriptorFILL(XYControllerPlugin) +}; + +// ----------------------------------------------------------------------- + +CARLA_EXPORT +void carla_register_native_plugin_xycontroller(); + +CARLA_EXPORT +void carla_register_native_plugin_xycontroller() +{ + carla_register_native_plugin(¬esDesc); +} + +// -----------------------------------------------------------------------