diff --git a/source/backend/native/3bandeq/DistrhoPlugin3BandEQ.cpp b/source/backend/native/3bandeq/DistrhoPlugin3BandEQ.cpp index e0d991cbf..e85ac5784 100644 --- a/source/backend/native/3bandeq/DistrhoPlugin3BandEQ.cpp +++ b/source/backend/native/3bandeq/DistrhoPlugin3BandEQ.cpp @@ -209,11 +209,11 @@ void DistrhoPlugin3BandEQ::d_setProgram(uint32_t index) void DistrhoPlugin3BandEQ::d_activate() { - xLP = exp(-2.0 * cfPI * freqLP / d_sampleRate()); + xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); a0LP = 1.0f - xLP; b1LP = -xLP; - xHP = exp(-2.0 * cfPI * freqHP / d_sampleRate()); + xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); a0HP = 1.0f - xHP; b1HP = -xHP; } @@ -226,8 +226,8 @@ void DistrhoPlugin3BandEQ::d_deactivate() void DistrhoPlugin3BandEQ::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*) { - const float* in1 = inputs[0]; - const float* in2 = inputs[1]; + float* in1 = inputs[0]; + float* in2 = inputs[1]; float* out1 = outputs[0]; float* out2 = outputs[1]; diff --git a/source/backend/native/3bandeq/DistrhoPluginInfo.h b/source/backend/native/3bandeq/DistrhoPluginInfo.h index 6e73edffe..e40fdb3a3 100644 --- a/source/backend/native/3bandeq/DistrhoPluginInfo.h +++ b/source/backend/native/3bandeq/DistrhoPluginInfo.h @@ -33,11 +33,10 @@ #ifdef QTCREATOR_TEST // TESTING -#include "3bandeq/DistrhoPluginInfo.h" # undef DISTRHO_PLUGIN_IS_SYNTH # undef DISTRHO_PLUGIN_WANT_LATENCY # undef DISTRHO_PLUGIN_WANT_STATE -# define DISTRHO_PLUGIN_IS_SYNTH 1 +# define DISTRHO_PLUGIN_IS_SYNTH 1 # define DISTRHO_PLUGIN_WANT_LATENCY 1 # define DISTRHO_PLUGIN_WANT_STATE 1 #endif diff --git a/source/backend/native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp b/source/backend/native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp index 9b0e17f1e..ced55e10b 100644 --- a/source/backend/native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp +++ b/source/backend/native/3bandsplitter/DistrhoPlugin3BandSplitter.cpp @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * For a full copy of the license see the LGPL.txt file @@ -209,11 +209,11 @@ void DistrhoPlugin3BandSplitter::d_setProgram(uint32_t index) void DistrhoPlugin3BandSplitter::d_activate() { - xLP = exp(-2.0 * cfPI * freqLP / d_sampleRate()); + xLP = std::exp(-2.0 * cfPI * freqLP / d_sampleRate()); a0LP = 1.0f - xLP; b1LP = -xLP; - xHP = exp(-2.0 * cfPI * freqHP / d_sampleRate()); + xHP = std::exp(-2.0 * cfPI * freqHP / d_sampleRate()); a0HP = 1.0f - xHP; b1HP = -xHP; } @@ -226,8 +226,8 @@ void DistrhoPlugin3BandSplitter::d_deactivate() void DistrhoPlugin3BandSplitter::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*) { - const float* in1 = inputs[0]; - const float* in2 = inputs[1]; + float* in1 = inputs[0]; + float* in2 = inputs[1]; float* out1 = outputs[0]; float* out2 = outputs[1]; float* out3 = outputs[2]; diff --git a/source/backend/native/Makefile b/source/backend/native/Makefile new file mode 100644 index 000000000..329823706 --- /dev/null +++ b/source/backend/native/Makefile @@ -0,0 +1,83 @@ +#!/usr/bin/make -f +# Makefile for carla-native # +# ------------------------------------ # +# Created by falkTX +# + +include ../../Makefile.mk + +# -------------------------------------------------------------- + +BUILD_C_FLAGS += -fvisibility=hidden -fPIC -I. -I.. -I../../includes +BUILD_CXX_FLAGS += -fvisibility=hidden -fPIC -I. -I.. -I../../includes -I../../utils -I../../libs/distrho-plugin-toolkit +BUILD_CXX_FLAGS += $(shell pkg-config --cflags QtCore QtGui) + +LINK_FLAGS += -shared +LINK_FLAGS += $(shell pkg-config --libs QtCore QtGui) + +ifeq ($(HAVE_ZYN_DEPS),true) +ZYN_CXX_FLAGS = $(BUILD_CXX_FLAGS) +ZYN_CXX_FLAGS += $(shell pkg-config --cflags fftw3 mxml) +LINK_FLAGS += $(shell pkg-config --libs fftw3 mxml) +endif + +# -------------------------------------------------------------- + +# Simple plugins +OBJS = \ + bypass.c.o \ + midi-split.c.o \ + midi-through.c.o + +# DISTRHO plugins +OBJS += \ + distrho-3bandeq.cpp.o \ + distrho-3bandsplitter.cpp.o \ + distrho-pingpongpan.cpp.o + +# ZynAddSubFX +ifeq ($(HAVE_ZYN_DEPS),true) +OBJS += \ + zynaddsubfx.cpp.o \ + zynaddsubfx-src.cpp.o +endif + +TARGET = ../carla_native.so + +# -------------------------------------------------------------- + +all: $(TARGET) + +clean: + rm -f $(OBJS) $(TARGET) + +# -------------------------------------------------------------- + +%.c.o: %.c + $(CC) $< $(BUILD_C_FLAGS) -c -o $@ + +%.cpp.o: %.cpp + $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ + +$(TARGET): $(OBJS) + $(CXX) $^ $(LINK_FLAGS) -o $@ + +# -------------------------------------------------------------- + +distrho-3bandeq.cpp.o: distrho-3bandeq.cpp + $(CXX) $< $(BUILD_CXX_FLAGS) -I3bandeq -DDISTRHO_NAMESPACE=DISTRHO_3BandEQ -c -o $@ + +distrho-3bandsplitter.cpp.o: distrho-3bandsplitter.cpp + $(CXX) $< $(BUILD_CXX_FLAGS) -I3bandsplitter -DDISTRHO_NAMESPACE=DISTRHO_3BandSplitter -c -o $@ + +distrho-pingpongpan.cpp.o: distrho-pingpongpan.cpp + $(CXX) $< $(BUILD_CXX_FLAGS) -Ipingpongpan -DDISTRHO_NAMESPACE=DISTRHO_PingPongPan -c -o $@ + +# distrho-pugl.o: distrho-pugl.cpp +# $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ + +zynaddsubfx.cpp.o: zynaddsubfx.cpp + $(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ + +zynaddsubfx-src.cpp.o: zynaddsubfx-src.cpp + $(CXX) $< $(ZYN_CXX_FLAGS) -c -o $@ diff --git a/source/backend/native/distrho-3bandeq.cpp b/source/backend/native/distrho-3bandeq.cpp index adaafe1f4..b49dbc0a3 100644 --- a/source/backend/native/distrho-3bandeq.cpp +++ b/source/backend/native/distrho-3bandeq.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2012 Filipe Coelho + * Copyright (C) 2012-2013 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 @@ -9,7 +9,7 @@ * * 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 + * 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 COPYING file @@ -31,7 +31,7 @@ START_NAMESPACE_DISTRHO static PluginDescriptor tBandEqDesc = { /* category */ ::PLUGIN_CATEGORY_EQ, - /* hints */ ::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI, + /* hints */ static_cast(::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI), /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, /* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, /* midiIns */ 0, diff --git a/source/backend/native/distrho-3bandsplitter.cpp b/source/backend/native/distrho-3bandsplitter.cpp index 4c509362d..44ce49eec 100644 --- a/source/backend/native/distrho-3bandsplitter.cpp +++ b/source/backend/native/distrho-3bandsplitter.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2012 Filipe Coelho + * Copyright (C) 2012-2013 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 @@ -9,7 +9,7 @@ * * 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 + * 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 COPYING file @@ -31,7 +31,7 @@ START_NAMESPACE_DISTRHO static PluginDescriptor tBandSplitterDesc = { /* category */ ::PLUGIN_CATEGORY_EQ, - /* hints */ ::PLUGIN_HAS_GUI, + /* hints */ static_cast(::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI), /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, /* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, /* midiIns */ 0, diff --git a/source/backend/native/distrho-pingpongpan.cpp b/source/backend/native/distrho-pingpongpan.cpp index 3315d362e..78b9e5ae2 100644 --- a/source/backend/native/distrho-pingpongpan.cpp +++ b/source/backend/native/distrho-pingpongpan.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2012 Filipe Coelho + * Copyright (C) 2012-2013 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 @@ -9,7 +9,7 @@ * * 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 + * 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 COPYING file @@ -31,7 +31,7 @@ START_NAMESPACE_DISTRHO static PluginDescriptor tBandEqDesc = { /* category */ ::PLUGIN_CATEGORY_UTILITY, - /* hints */ ::PLUGIN_HAS_GUI, + /* hints */ static_cast(::PLUGIN_IS_RTSAFE | ::PLUGIN_HAS_GUI), /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, /* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, /* midiIns */ 0, diff --git a/source/backend/native/distrho/DistrhoPluginCarla.cpp b/source/backend/native/distrho/DistrhoPluginCarla.cpp index aa88ff4a3..43f9d1ef8 100644 --- a/source/backend/native/distrho/DistrhoPluginCarla.cpp +++ b/source/backend/native/distrho/DistrhoPluginCarla.cpp @@ -1,6 +1,6 @@ /* * DISTHRO Plugin Toolkit (DPT) - * Copyright (C) 2012 Filipe Coelho + * Copyright (C) 2012-2013 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 @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file @@ -40,26 +40,16 @@ public: : QDialog(nullptr), m_host(host), m_plugin(plugin), - ui(this, realWinId(), setParameterCallback, setStateCallback, uiEditParameterCallback, uiSendNoteCallback, uiResizeCallback) + ui(this, (intptr_t)winId(), setParameterCallback, setStateCallback, uiEditParameterCallback, uiSendNoteCallback, uiResizeCallback) { setFixedSize(ui.getWidth(), ui.getHeight()); - setWindowTitle("TEST GUI"); + setWindowTitle(DISTRHO_PLUGIN_NAME); } ~UICarla() { } - intptr_t realWinId() const - { - WId wId = winId(); -#if DISTRHO_OS_WINDOWS - return (intptr_t)static_cast(wId); -#else - return wId; -#endif - } - // --------------------------------------------- void carla_show(const bool yesNo) @@ -142,20 +132,19 @@ private: static void setParameterCallback(void* ptr, uint32_t rindex, float value) { - UICarla* _this_ = (UICarla*)ptr; - CARLA_ASSERT(_this_); - - _this_->setParameterValue(rindex, value); + if (UICarla* _this_ = (UICarla*)ptr) + _this_->setParameterValue(rindex, value); } static void setStateCallback(void* ptr, const char* key, const char* value) { # if DISTRHO_PLUGIN_WANT_STATE - UICarla* _this_ = (UICarla*)ptr; - CARLA_ASSERT(_this_); - - _this_->setState(key, value); + if (UICarla* _this_ = (UICarla*)ptr) + _this_->setState(key, value); # else + return; + + // unused Q_UNUSED(ptr); Q_UNUSED(key); Q_UNUSED(value); @@ -164,20 +153,19 @@ private: static void uiEditParameterCallback(void* ptr, uint32_t index, bool started) { - UICarla* _this_ = (UICarla*)ptr; - CARLA_ASSERT(_this_); - - _this_->uiEditParameter(index, started); + if (UICarla* _this_ = (UICarla*)ptr) + _this_->uiEditParameter(index, started); } static void uiSendNoteCallback(void* ptr, bool onOff, uint8_t channel, uint8_t note, uint8_t velocity) { # if DISTRHO_PLUGIN_IS_SYNTH - UICarla* _this_ = (UICarla*)ptr; - CARLA_ASSERT(_this_); - - _this_->uiSendNote(onOff, channel, note, velocity); + if (UICarla* _this_ = (UICarla*)ptr) + _this_->uiSendNote(onOff, channel, note, velocity); # else + return; + + // unused Q_UNUSED(ptr); Q_UNUSED(onOff); Q_UNUSED(channel); @@ -188,10 +176,8 @@ private: static void uiResizeCallback(void* ptr, unsigned int width, unsigned int height) { - UICarla* _this_ = (UICarla*)ptr; - CARLA_ASSERT(_this_); - - _this_->uiResize(width, height); + if (UICarla* _this_ = (UICarla*)ptr) + _this_->uiResize(width, height); } }; #endif @@ -236,21 +222,24 @@ protected: { const uint32_t paramHints = plugin.parameterHints(index); + int nativeparamHints = 0; if (paramHints & PARAMETER_IS_AUTOMABLE) - param.hints |= ::PARAMETER_IS_AUTOMABLE; + nativeparamHints |= ::PARAMETER_IS_AUTOMABLE; if (paramHints & PARAMETER_IS_BOOLEAN) - param.hints |= ::PARAMETER_IS_BOOLEAN; + nativeparamHints |= ::PARAMETER_IS_BOOLEAN; if (paramHints & PARAMETER_IS_INTEGER) - param.hints |= ::PARAMETER_IS_INTEGER; + nativeparamHints |= ::PARAMETER_IS_INTEGER; if (paramHints & PARAMETER_IS_LOGARITHMIC) - param.hints |= ::PARAMETER_IS_LOGARITHMIC; + nativeparamHints |= ::PARAMETER_IS_LOGARITHMIC; if (paramHints & PARAMETER_IS_OUTPUT) - param.hints |= ::PARAMETER_IS_OUTPUT; + nativeparamHints |= ::PARAMETER_IS_OUTPUT; + + param.hints = static_cast(nativeparamHints); } - param.name = plugin.parameterName(index); - param.unit = plugin.parameterUnit(index); + param.name = plugin.parameterName(index); + param.unit = plugin.parameterUnit(index); { const ParameterRanges& ranges(plugin.parameterRanges(index)); diff --git a/source/backend/native/pingpongpan/DistrhoPluginPingPongPan.cpp b/source/backend/native/pingpongpan/DistrhoPluginPingPongPan.cpp index 2b4f51a47..08a785a40 100644 --- a/source/backend/native/pingpongpan/DistrhoPluginPingPongPan.cpp +++ b/source/backend/native/pingpongpan/DistrhoPluginPingPongPan.cpp @@ -136,8 +136,8 @@ void DistrhoPluginPingPongPan::d_deactivate() void DistrhoPluginPingPongPan::d_run(float** inputs, float** outputs, uint32_t frames, uint32_t, const MidiEvent*) { - const float* in1 = inputs[0]; - const float* in2 = inputs[1]; + float* in1 = inputs[0]; + float* in2 = inputs[1]; float* out1 = outputs[0]; float* out2 = outputs[1]; diff --git a/source/libs/distrho-plugin-toolkit/DistrhoPlugin.h b/source/libs/distrho-plugin-toolkit/DistrhoPlugin.h index 32b6633fb..b966160ea 100644 --- a/source/libs/distrho-plugin-toolkit/DistrhoPlugin.h +++ b/source/libs/distrho-plugin-toolkit/DistrhoPlugin.h @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file @@ -90,10 +90,7 @@ struct Parameter { ParameterRanges ranges; Parameter() - : hints(0x0), - name(nullptr), - symbol(nullptr), - unit(nullptr) {} + : hints(0x0) {} }; // ------------------------------------------------- @@ -104,8 +101,9 @@ struct MidiEvent { uint8_t buffer[3]; MidiEvent() - : frame(0), - buffer{0} {} + { + clear(); + } void clear() { diff --git a/source/libs/distrho-plugin-toolkit/DistrhoPluginMain.cpp b/source/libs/distrho-plugin-toolkit/DistrhoPluginMain.cpp index 22da58036..26403a7d5 100644 --- a/source/libs/distrho-plugin-toolkit/DistrhoPluginMain.cpp +++ b/source/libs/distrho-plugin-toolkit/DistrhoPluginMain.cpp @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file diff --git a/source/libs/distrho-plugin-toolkit/DistrhoUtils.h b/source/libs/distrho-plugin-toolkit/DistrhoUtils.h index d1d0a313b..ef334e06a 100644 --- a/source/libs/distrho-plugin-toolkit/DistrhoUtils.h +++ b/source/libs/distrho-plugin-toolkit/DistrhoUtils.h @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file diff --git a/source/libs/distrho-plugin-toolkit/src/DistrhoDefines.h b/source/libs/distrho-plugin-toolkit/src/DistrhoDefines.h index a35d4c890..39e0633eb 100644 --- a/source/libs/distrho-plugin-toolkit/src/DistrhoDefines.h +++ b/source/libs/distrho-plugin-toolkit/src/DistrhoDefines.h @@ -15,8 +15,8 @@ * For a full copy of the license see the GPL.txt file */ -#ifndef __DISTRHO_DEFINES_HPP__ -#define __DISTRHO_DEFINES_HPP__ +#ifndef __DISTRHO_DEFINES_H__ +#define __DISTRHO_DEFINES_H__ #if defined(__WIN32__) || defined(__WIN64__) # define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport) @@ -53,4 +53,4 @@ # define USE_NAMESPACE_DISTRHO #endif -#endif // __DISTRHO_DEFINES_HPP__ +#endif // __DISTRHO_DEFINES_H__ diff --git a/source/libs/distrho-plugin-toolkit/src/DistrhoMacros.h b/source/libs/distrho-plugin-toolkit/src/DistrhoMacros.h index 447d1e422..d45881f98 100644 --- a/source/libs/distrho-plugin-toolkit/src/DistrhoMacros.h +++ b/source/libs/distrho-plugin-toolkit/src/DistrhoMacros.h @@ -15,8 +15,8 @@ * For a full copy of the license see the GPL.txt file */ -#ifndef __DISTRHO_MACROS_HPP__ -#define __DISTRHO_MACROS_HPP__ +#ifndef __DISTRHO_MACROS_H__ +#define __DISTRHO_MACROS_H__ #include "DistrhoDefines.h" #include "DistrhoPluginInfo.h" @@ -59,4 +59,4 @@ #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" -#endif // __DISTRHO_MACROS_HPP__ +#endif // __DISTRHO_MACROS_H__ diff --git a/source/libs/distrho-plugin-toolkit/src/DistrhoPlugin.cpp b/source/libs/distrho-plugin-toolkit/src/DistrhoPlugin.cpp index b28dee653..e3717ee5a 100644 --- a/source/libs/distrho-plugin-toolkit/src/DistrhoPlugin.cpp +++ b/source/libs/distrho-plugin-toolkit/src/DistrhoPlugin.cpp @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file @@ -41,14 +41,14 @@ Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCou if (parameterCount > 0) { data->parameterCount = parameterCount; - data->parameters = new Parameter [parameterCount]; + data->parameters = new Parameter[parameterCount]; } if (programCount > 0) { #if DISTRHO_PLUGIN_WANT_PROGRAMS data->programCount = programCount; - data->programNames = new d_string [programCount]; + data->programNames = new d_string[programCount]; #endif } @@ -56,7 +56,7 @@ Plugin::Plugin(uint32_t parameterCount, uint32_t programCount, uint32_t stateCou { #if DISTRHO_PLUGIN_WANT_STATE data->stateCount = stateCount; - data->stateKeys = new d_string [stateCount]; + data->stateKeys = new d_string[stateCount]; #endif } } diff --git a/source/libs/distrho-plugin-toolkit/src/DistrhoPluginInternal.h b/source/libs/distrho-plugin-toolkit/src/DistrhoPluginInternal.h index 89f8081af..3f16bf459 100644 --- a/source/libs/distrho-plugin-toolkit/src/DistrhoPluginInternal.h +++ b/source/libs/distrho-plugin-toolkit/src/DistrhoPluginInternal.h @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file @@ -42,12 +42,10 @@ struct PluginPrivateData { uint32_t programCount; d_string* programNames; #endif - #if DISTRHO_PLUGIN_WANT_STATE uint32_t stateCount; d_string* stateKeys; #endif - #if DISTRHO_PLUGIN_WANT_LATENCY uint32_t latency; #endif @@ -308,10 +306,10 @@ public: if (data) { - data->bufferSize = bufferSize; - if (callback && data->bufferSize == bufferSize) callback = false; + + data->bufferSize = bufferSize; } if (plugin && callback) @@ -328,10 +326,10 @@ public: if (data) { - data->sampleRate = sampleRate; - if (callback && data->sampleRate == sampleRate) callback = false; + + data->sampleRate = sampleRate; } if (plugin && callback) diff --git a/source/libs/distrho-plugin-toolkit/src/DistrhoUIInternal.h b/source/libs/distrho-plugin-toolkit/src/DistrhoUIInternal.h index 033849dc9..daf3f7b6a 100644 --- a/source/libs/distrho-plugin-toolkit/src/DistrhoUIInternal.h +++ b/source/libs/distrho-plugin-toolkit/src/DistrhoUIInternal.h @@ -9,7 +9,7 @@ * * 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * For a full copy of the license see the GPL.txt file @@ -41,9 +41,9 @@ START_NAMESPACE_DISTRHO // ------------------------------------------------- #ifdef DISTRHO_UI_OPENGL -typedef PuglView* NativeWidget; +typedef PuglView NativeWidget; #else -typedef QWidget* NativeWidget; +typedef QWidget NativeWidget; #endif typedef void (*setParamFunc) (void* ptr, uint32_t index, float value); @@ -80,8 +80,8 @@ struct UIPrivateData { uint32_t parameterOffset; // UI - void* ptr; - NativeWidget widget; + void* ptr; + NativeWidget* widget; // Callbacks setParamFunc setParamCallbackFunc; @@ -261,7 +261,12 @@ public: void createWindow(intptr_t parent) { #ifdef DISTRHO_UI_QT4 - assert(ui && ! qt_widget); + assert(ui && data && ! qt_widget); + + if (qt_widget || ! (ui && data)) + return; + + qt_mouseDown = false; // create embedable widget qt_widget = new QEmbedWidget; @@ -293,9 +298,9 @@ public: // show it qt_widget->show(); #else - assert(ui); + assert(ui && data && ! data->widget); - if ((data && data->widget) || ! ui) + if ((! data) || data->widget || ! ui) return; data->widget = puglCreate(parent, DISTRHO_PLUGIN_NAME, ui->d_width(), ui->d_height(), false); @@ -331,9 +336,13 @@ public: qt_widget->close(); if (qt_grip) + { delete qt_grip; + qt_grip = nullptr; + } delete qt_widget; + qt_widget = nullptr; } #else ((OpenGLUI*)ui)->d_onClose(); @@ -351,46 +360,31 @@ public: #ifdef DISTRHO_UI_OPENGL void gl_onDisplay() { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onDisplay(); } void gl_onKeyboard(bool press, uint32_t key) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onKeyboard(press, key); } void gl_onMotion(int x, int y) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onMotion(x, y); } void gl_onMouse(int button, bool press, int x, int y) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onMouse(button, press, x, y); } void gl_onReshape(int width, int height) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) { if (! gl_initiated) { @@ -404,32 +398,24 @@ public: void gl_onScroll(float dx, float dy) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onScroll(dx, dy); } void gl_onSpecial(bool press, Key key) { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onSpecial(press, key); } void gl_onClose() { - OpenGLUI* uiGL = (OpenGLUI*)ui; - assert(uiGL); - - if (uiGL) + if (OpenGLUI* uiGL = (OpenGLUI*)ui) uiGL->d_onClose(); } // --------------------------------------------- +private: static void gl_onDisplayCallback(PuglView* view) {