From b0f5706efebd68fdd62cccdf05404f1786decaf1 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 3 Oct 2013 16:13:29 +0100 Subject: [PATCH] Fixing --- source/backend/standalone/CarlaStandalone.cpp | 4 +- source/backend/standalone/Makefile | 4 +- source/carla_host.py | 6 +- source/modules/carla_native/vex.cpp | 145 ++++++++++++++++-- source/modules/juce_graphics/AppConfig.h | 4 +- source/modules/juce_graphics/Makefile | 3 + 6 files changed, 142 insertions(+), 24 deletions(-) diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index b07d47fb8..4751cefc2 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -17,7 +17,6 @@ // TODO: // Check carla_stderr2("Engine is not running"); <= prepend func name and args -// Check NSM args #include "CarlaHost.hpp" #include "CarlaEngine.hpp" @@ -76,7 +75,7 @@ struct CarlaBackendStandalone { void idle() { if (MessageManager* const mgr = MessageManager::getInstanceWithoutCreating()) - mgr->runDispatchLoopUntil(0); + mgr->runDispatchLoopUntil(5); } void close() @@ -454,6 +453,7 @@ void carla_engine_idle() { CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,); + gStandalone.idle(); gStandalone.engine->idle(); } diff --git a/source/backend/standalone/Makefile b/source/backend/standalone/Makefile index f04109cf3..f95042143 100644 --- a/source/backend/standalone/Makefile +++ b/source/backend/standalone/Makefile @@ -76,7 +76,7 @@ LINK_FLAGS += $(shell pkg-config --libs ntk_images ntk) endif endif -EXTRA_LIBS = -ldl -lfreetype +EXTRA_LIBS = -ldl -lfreetype -lXext LINK_FLAGS += $(EXTRA_LIBS) ifneq ($(MACOS),true) @@ -92,6 +92,8 @@ LIBS += ../../modules/juce_audio_basics.a LIBS += ../../modules/juce_core.a LIBS += ../../modules/juce_data_structures.a LIBS += ../../modules/juce_events.a +LIBS += ../../modules/juce_graphics.a +LIBS += ../../modules/juce_gui_basics.a LIBS += ../../modules/rtmempool.a ifeq ($(CARLA_PLUGIN_SUPPORT),true) diff --git a/source/carla_host.py b/source/carla_host.py index 4b1633806..501846f34 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -380,7 +380,7 @@ class HostWindow(QMainWindow): #self.fFirstEngineInit = False # Peaks and TimeInfo - self.fIdleTimerFast = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]) + self.fIdleTimerFast = self.startTimer(30) #self.fSavedSettings["Main/RefreshInterval"]) # LEDs and edit dialog parameters self.fIdleTimerSlow = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]*2) @@ -591,7 +591,7 @@ class HostWindow(QMainWindow): if self.fIdleTimerFast != 0: self.killTimer(self.fIdleTimerFast) - self.fIdleTimerFast = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]) + self.fIdleTimerFast = self.startTimer(30) #self.fSavedSettings["Main/RefreshInterval"]) if self.fIdleTimerSlow != 0: self.killTimer(self.fIdleTimerSlow) @@ -864,7 +864,7 @@ class HostWindow(QMainWindow): self.fSampleRate = Carla.host.get_sample_rate() if self.fIdleTimerFast == 0: - self.fIdleTimerFast = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]) + self.fIdleTimerFast = self.startTimer(30) #self.fSavedSettings["Main/RefreshInterval"]) if self.fIdleTimerSlow == 0: self.fIdleTimerSlow = self.startTimer(self.fSavedSettings["Main/RefreshInterval"]*2) diff --git a/source/modules/carla_native/vex.cpp b/source/modules/carla_native/vex.cpp index 3b181a0cf..acaa0c8a1 100644 --- a/source/modules/carla_native/vex.cpp +++ b/source/modules/carla_native/vex.cpp @@ -27,9 +27,66 @@ using namespace juce; #include "vex/VexReverb.h" #include "vex/VexSyntModule.h" +#include "vex/PeggyViewComponent.h" + +// ----------------------------------------------------------------------- + +class HelperWindow : public DocumentWindow +{ +public: + HelperWindow() + : DocumentWindow("PlugWindow", Colour(0, 0, 0), DocumentWindow::closeButton, false), + fClosed(false) + { + setDropShadowEnabled(false); + setOpaque(true); + setResizable(false, false); + //setUsingNativeTitleBar(true); + setVisible(false); + } + + void show(Component* const comp) + { + fClosed = false; + + setContentNonOwned(comp, true); + centreWithSize(comp->getWidth(), comp->getHeight()); + + if (! isOnDesktop()) + addToDesktop(); + + setVisible(true); + } + + void hide() + { + setVisible(false); + + if (isOnDesktop()) + removeFromDesktop(); + + clearContentComponent(); + } + + bool wasClosedByUser() const + { + return fClosed; + } + +protected: + void closeButtonPressed() override + { + fClosed = true; + } + +private: + bool fClosed; +}; + // ----------------------------------------------------------------------- -class VexArpPlugin : public PluginClass +class VexArpPlugin : public PluginClass, + public PeggyViewComponent::Callback { public: enum Params { @@ -46,19 +103,6 @@ public: : PluginClass(host), fArp(&fSettings) { - for (int i=0; i < 8; ++i) - fSettings.grid[i*10] = true; - - fSettings.grid[1] = true; - fSettings.grid[2] = true; - fSettings.grid[3] = true; - - fSettings.grid[41] = true; - fSettings.grid[42] = true; - fSettings.grid[43] = true; - fSettings.grid[44] = true; - fSettings.grid[45] = true; - fArp.setSampleRate(getSampleRate()); fMidiInBuffer.ensureSize(512*4); } @@ -285,6 +329,56 @@ protected: } } + // ------------------------------------------------------------------- + // Plugin UI calls + + void uiShow(const bool show) override + { + if (show) + { + if (fWindow == nullptr) + { + fWindow = new HelperWindow(); + fWindow->setName(getUiName()); + } + + if (fView == nullptr) + { + fView = new PeggyViewComponent(1, fSettings, this); + fView->setSize(207, 280); + } + + fWindow->show(fView); + } + else if (fWindow != nullptr) + { + fWindow->hide(); + + fView = nullptr; + fWindow = nullptr; + } + } + + void uiIdle() override + { + if (fWindow == nullptr) + return; + + if (fWindow->wasClosedByUser()) + { + uiShow(false); + uiClosed(); + } + } + + void uiSetParameterValue(const uint32_t, const float) override + { + if (fView == nullptr) + return; + + fView->update(); + } + // ------------------------------------------------------------------- // Plugin dispatcher calls @@ -293,11 +387,30 @@ protected: fArp.setSampleRate(sampleRate); } + void uiNameChanged(const char* const uiName) override + { + if (fWindow == nullptr) + return; + + fWindow->setName(uiName); + } + + // ------------------------------------------------------------------- + // Peggy callback + + void somethingChanged(const uint32_t id) override + { + uiParameterChanged(id, getParameterValue(id)); + } + private: VexArpSettings fSettings; VexArp fArp; MidiBuffer fMidiInBuffer; + ScopedPointer fView; + ScopedPointer fWindow; + PluginClassEND(VexArpPlugin) CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(VexArpPlugin) }; @@ -1029,7 +1142,7 @@ protected: } } - if (obf->getNumSamples() != frames) + if (obf->getNumSamples() != (int)frames) { obf->setSize(2, frames, 0, 0, 1); abf->setSize(2, frames, 0, 0, 1); @@ -1110,7 +1223,7 @@ private: static const PluginDescriptor vexArpDesc = { /* category */ PLUGIN_CATEGORY_UTILITY, - /* hints */ static_cast(PLUGIN_USES_TIME), + /* hints */ static_cast(PLUGIN_HAS_GUI|PLUGIN_NEEDS_SINGLE_THREAD|PLUGIN_USES_TIME), /* supports */ static_cast(PLUGIN_SUPPORTS_EVERYTHING), /* audioIns */ 0, /* audioOuts */ 0, diff --git a/source/modules/juce_graphics/AppConfig.h b/source/modules/juce_graphics/AppConfig.h index bb99bb77d..dc638e376 100755 --- a/source/modules/juce_graphics/AppConfig.h +++ b/source/modules/juce_graphics/AppConfig.h @@ -28,9 +28,9 @@ */ #define JUCE_USE_DIRECTWRITE 1 -#define JUCE_INCLUDE_PNGLIB_CODE 0 +#define JUCE_INCLUDE_PNGLIB_CODE 1 -#define JUCE_INCLUDE_JPEGLIB_CODE 0 +#define JUCE_INCLUDE_JPEGLIB_CODE 1 #define USE_COREGRAPHICS_RENDERING 1 diff --git a/source/modules/juce_graphics/Makefile b/source/modules/juce_graphics/Makefile index 20bd05054..49ef9841b 100644 --- a/source/modules/juce_graphics/Makefile +++ b/source/modules/juce_graphics/Makefile @@ -19,6 +19,9 @@ else OBJS = juce_graphics.cpp.o OBJS_posix32 = juce_graphics.cpp.posix32.o OBJS_posix64 = juce_graphics.cpp.posix64.o +ifneq ($(WIN32),true) +BUILD_CXX_FLAGS += $(shell pkg-config --cflags freetype2) +endif endif OBJS_win32 = juce_graphics.cpp.win32.o