diff --git a/.gitignore b/.gitignore index c24221b94..a78890c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -90,6 +90,9 @@ carla-discovery-posix64 carla-frontend carla-lv2-export +rev1-ui +zynaddsubfx-ui + data/stoat-callgraph.png data/linux/unzipfx2cat32 data/linux/unzipfx2cat64 diff --git a/Makefile b/Makefile index 17796a559..f2e790ea7 100644 --- a/Makefile +++ b/Makefile @@ -529,6 +529,10 @@ ifeq ($(EXPERIMENTAL_PLUGINS),true) install -m 644 \ bin/resources/rev1/*.png \ $(DESTDIR)$(PREFIX)/share/carla/resources/rev1/ + + install -m 755 \ + bin/resources/rev1-ui \ + $(DESTDIR)$(PREFIX)/share/carla/resources/ endif install -m 644 \ diff --git a/source/native-plugins/Makefile b/source/native-plugins/Makefile index 28bca1037..a288a6358 100644 --- a/source/native-plugins/Makefile +++ b/source/native-plugins/Makefile @@ -29,7 +29,7 @@ ifeq ($(HAVE_NTK),true) FLUID = ntk-fluid ZYN_CXX_FLAGS += -DNTK_GUI ZYN_CXX_FLAGS += $(shell pkg-config --cflags ntk_images ntk) -ZYN_LD_FLAGS += $(shell pkg-config --libs ntk_images ntk) -ldl +ZYN_LD_FLAGS += $(shell pkg-config --libs ntk_images ntk) else # HAVE_NTK FLUID = fluid ZYN_CXX_FLAGS += -DFLTK_GUI @@ -155,6 +155,8 @@ OBJS += \ $(OBJDIR)/zita-at1.cpp.o \ $(OBJDIR)/zita-bls1.cpp.o \ $(OBJDIR)/zita-rev1.cpp.o + +TARGETS += resources/rev1-ui$(APP_EXT) endif # ---------------------------------------------------------------------------------------------------------------------------- @@ -177,10 +179,15 @@ $(MODULEDIR)/$(MODULENAME).a: $(OBJS) @rm -f $@ @$(AR) crs $@ $^ +resources/rev1-ui$(APP_EXT): $(OBJDIR)/zita-rev1-ui.cpp.o + -@mkdir -p $(OBJDIR) + @echo "Linking zita-rev1-ui" + @$(CXX) $^ $(LINK_FLAGS) -lclxclient -lclthreads $(shell pkg-config --libs cairo libpng12 x11 xft zlib) -ldl -lpthread -o $@ + resources/zynaddsubfx-ui$(APP_EXT): $(OBJDIR)/zynaddsubfx-ui.cpp.o -@mkdir -p $(OBJDIR) @echo "Linking zynaddsubfx-ui" - @$(CXX) $^ $(ZYN_LD_FLAGS) -o $@ + @$(CXX) $^ $(ZYN_LD_FLAGS) -ldl -lpthread -o $@ # ---------------------------------------------------------------------------------------------------------------------------- @@ -287,7 +294,12 @@ $(OBJDIR)/zita-bls1.cpp.o: zita-bls1.cpp $(OBJDIR)/zita-rev1.cpp.o: zita-rev1.cpp -@mkdir -p $(OBJDIR) @echo "Compiling $<" - @$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags fftw3f x11 xft) -Wno-unused-parameter -Wno-unused-result -c -o $@ + @$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags fftw3f) -Wno-unused-parameter -c -o $@ + +$(OBJDIR)/zita-rev1-ui.cpp.o: zita-rev1-ui.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling $<" + @$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags cairo libpng12 x11 xft zlib) -Wno-unused-parameter -Wno-ignored-qualifiers -c -o $@ # ---------------------------------------------------------------------------------------------------------------------------- @@ -299,6 +311,7 @@ $(OBJDIR)/%.cpp.o: %.cpp # ---------------------------------------------------------------------------------------------------------------------------- -include $(OBJS:%.o=%.d) +-include $(OBJDIR)/zita-rev-ui.cpp.d -include $(OBJDIR)/zynaddsubfx-ui.cpp.d # ---------------------------------------------------------------------------------------------------------------------------- diff --git a/source/native-plugins/zita-rev1-ui.cpp b/source/native-plugins/zita-rev1-ui.cpp new file mode 100644 index 000000000..a1454b44d --- /dev/null +++ b/source/native-plugins/zita-rev1-ui.cpp @@ -0,0 +1,196 @@ +/* + * Carla Native Plugins + * Copyright (C) 2012-2015 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 "CarlaPipeUtils.cpp" + +#include "zita-rev1/png2img.cc" +#include "zita-rev1/guiclass.cc" +#include "zita-rev1/mainwin.cc" +#include "zita-rev1/rotary.cc" +#include "zita-rev1/styles.cc" + +using namespace REV1; + +static Mainwin* mainwin = nullptr; + +// -------------------------------------------------------------------------------------------- + +class ZitaPipeClient : public CarlaPipeClient, + public Mainwin::ValueChangedCallback +{ +public: + ZitaPipeClient() noexcept + : CarlaPipeClient(), + fQuitReceived(false) {} + + ~ZitaPipeClient() noexcept override + { + if (fQuitReceived) + return; + + const CarlaMutexLocker cml(getPipeLock()); + + writeMessage("exiting\n"); + flushMessages(); + } + + bool quitRequested() const noexcept + { + return fQuitReceived; + } + +protected: + bool msgReceived(const char* const msg) noexcept override + { + if (std::strcmp(msg, "control") == 0) + { + uint index; + float value; + CARLA_SAFE_ASSERT_RETURN(readNextLineAsUInt(index), true); + CARLA_SAFE_ASSERT_RETURN(readNextLineAsFloat(value), true); + + if (index == Mainwin::R_OPMIX && mainwin->_ambis) + index = Mainwin::R_RGXYZ; + + mainwin->_rotary[index]->set_value(value); + return true; + } + + if (std::strcmp(msg, "show") == 0) + { + mainwin->x_map(); + return true; + } + + if (std::strcmp(msg, "hide") == 0) + { + mainwin->x_unmap(); + return true; + } + + if (std::strcmp(msg, "focus") == 0) + { + mainwin->x_mapraised(); + return true; + } + + if (std::strcmp(msg, "uiTitle") == 0) + { + const char* uiTitle; + + CARLA_SAFE_ASSERT_RETURN(readNextLineAsString(uiTitle), true); + + mainwin->x_set_title(uiTitle); + return true; + } + + if (std::strcmp(msg, "quit") == 0) + { + fQuitReceived = true; + return true; + } + + carla_stderr("ZitaPipeClient::msgReceived : %s", msg); + return false; + } + + void valueChangedCallback(uint index, double value) override + { + if (index == Mainwin::R_RGXYZ) + index = Mainwin::R_OPMIX; + + writeControlMessage(index, value); + } + +private: + bool fQuitReceived; +}; + +// -------------------------------------------------------------------------------------------- + +int main(int argc, const char* argv[]) +{ + X_resman xresman; + X_display *display; + X_handler *handler; + X_rootwin *rootwin; + int ev, xp, yp, xs, ys; + + int fake_argc = 1; + char* fake_argv[] = { (char*)"rev1" }; + xresman.init(&fake_argc, fake_argv, (char*)"rev1", nullptr, 0); + + display = new X_display(nullptr); + if (display->dpy () == 0) + { + carla_stderr("Can't open display."); + delete display; + return 1; + } + + ZitaPipeClient pipe; + bool ambisonic = false; + const char* uiTitle = "Test UI"; + + if (argc > 1) + { + ambisonic = std::strcmp(argv[1], "true") == 0; + uiTitle = argv[2]; + + if (! pipe.initPipeClient(argv)) + return 1; + } + + xp = yp = 100; + xs = Mainwin::XSIZE + 4; + ys = Mainwin::YSIZE + 30; + xresman.geometry(".geometry", display->xsize(), display->ysize(), 1, xp, yp, xs, ys); + + styles_init(display, &xresman); + rootwin = new X_rootwin(display); + mainwin = new Mainwin(rootwin, &xresman, xp, yp, ambisonic, &pipe); + mainwin->x_set_title(uiTitle); + rootwin->handle_event(); + handler = new X_handler(display, mainwin, EV_X11); + handler->next_event(); + XFlush(display->dpy()); + + do + { + ev = mainwin->process(); + if (ev == EV_X11) + { + rootwin->handle_event(); + handler->next_event(); + } + else if (ev == Esync::EV_TIME) + { + handler->next_event(); + pipe.idlePipe(); + } + } + while (ev != EV_EXIT && ! pipe.quitRequested()); + + styles_fini(display); + delete handler; + delete rootwin; + delete display; + + return 0; +} + +// -------------------------------------------------------------------------------------------- diff --git a/source/native-plugins/zita-rev1.cpp b/source/native-plugins/zita-rev1.cpp index 1c1b36a89..093de8853 100644 --- a/source/native-plugins/zita-rev1.cpp +++ b/source/native-plugins/zita-rev1.cpp @@ -15,21 +15,14 @@ * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ -#include "CarlaNative.hpp" -#include "CarlaMathUtils.hpp" +#include "CarlaNativeExtUI.hpp" #include "CarlaJuceUtils.hpp" #include "juce_audio_basics.h" -#include "zita-common.hpp" -#include "zita-rev1/guiclass.cc" #include "zita-rev1/jclient.cc" -#include "zita-rev1/mainwin.cc" #include "zita-rev1/pareq.cc" -#include "zita-rev1/png2img.cc" #include "zita-rev1/reverb.cc" -#include "zita-rev1/rotary.cc" -#include "zita-rev1/styles.cc" using juce::FloatVectorOperations; using juce::ScopedPointer; @@ -39,9 +32,7 @@ using namespace REV1; // ----------------------------------------------------------------------- // REV1 Plugin -class REV1Plugin : public NativePluginClass, - public X_handler_thread::SetValueCallback, - private Mainwin::ValueChangedCallback +class REV1Plugin : public NativePluginAndUiClass { public: enum Parameters { @@ -59,18 +50,12 @@ public: }; REV1Plugin(const NativeHostDescriptor* const host, const bool isAmbisonic) - : NativePluginClass(host), + : NativePluginAndUiClass(host, "rev1-ui"), kIsAmbisonic(isAmbisonic), kNumInputs(2), kNumOutputs(isAmbisonic ? 4 : 2), fJackClient(), - xresman(), jclient(nullptr), - display(nullptr), - rootwin(nullptr), - mainwin(nullptr), - handler(nullptr), - handlerThread(this), leakDetector_REV1Plugin() { CARLA_SAFE_ASSERT(host != nullptr); @@ -81,11 +66,7 @@ public: fJackClient.bufferSize = getBufferSize(); fJackClient.sampleRate = getSampleRate(); - int argc = 1; - char* argv[] = { (char*)"rev1" }; - xresman.init(&argc, argv, (char*)"rev1", nullptr, 0); - - jclient = new Jclient(xresman.rname(), &fJackClient, isAmbisonic); + jclient = new Jclient(&fJackClient, isAmbisonic); // set initial values fParameters[kParameterDELAY] = 0.04f; @@ -319,78 +300,6 @@ public: fJackClient.processCallback(frames, fJackClient.processPtr); } - // ------------------------------------------------------------------- - // Plugin UI calls - - void uiShow(const bool show) override - { - if (show) - { - if (display != nullptr) - return; - - display = new X_display(nullptr); - - if (display->dpy() == nullptr) - return hostUiUnavailable(); - - styles_init(display, &xresman, getResourceDir()); - - rootwin = new X_rootwin(display); - mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient, this); - rootwin->handle_event(); - mainwin->x_set_title(getUiName()); - - handler = new X_handler(display, mainwin, EV_X11); - - if (const uintptr_t winId = getUiParentId()) - XSetTransientForHint(display->dpy(), mainwin->win(), static_cast(winId)); - - handler->next_event(); - XFlush(display->dpy()); - - handlerThread.setupAndRun(handler, rootwin, mainwin); - } - else - { - if (handlerThread.isThreadRunning()) - handlerThread.stopThread(); - - handler = nullptr; - mainwin = nullptr; - rootwin = nullptr; - display = nullptr; - } - } - - void uiIdle() override - { - if (mainwin == nullptr) - return; - - if (handlerThread.wasClosed()) - { - { - const CarlaMutexLocker cml(handlerThread.getLock()); - handler = nullptr; - mainwin = nullptr; - rootwin = nullptr; - display = nullptr; - } - uiClosed(); - } - } - - void uiSetParameterValue(const uint32_t index, const float value) override - { - CARLA_SAFE_ASSERT_RETURN(index < kParameterNROTARY,); - - if (mainwin == nullptr) - return; - - handlerThread.setParameterValueLater(index, value); - } - // ------------------------------------------------------------------- // Plugin dispatcher calls @@ -404,45 +313,35 @@ public: fJackClient.sampleRate = sampleRate; } - void uiNameChanged(const char* const uiName) override - { - CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',); - - if (mainwin == nullptr) - return; - - const CarlaMutexLocker cml(handlerThread.getLock()); - - mainwin->x_set_title(uiName); - } - - // ------------------------------------------------------------------- - // Mainwin callbacks - - void valueChangedCallback(uint rindex, double value) override - { - uint32_t index = rindex; - - if (kIsAmbisonic && rindex == kParameterNROTARY) - index = kParameterOPMIXorRGXYZ; - - fParameters[index] = value; - uiParameterChanged(index, value); - } - // ------------------------------------------------------------------- - // X_handler_thread callbacks + // Plugin UI calls - void setParameterValueFromHandlerThread(uint32_t index, float value) override + void uiShow(const bool show) override { - CARLA_SAFE_ASSERT_RETURN(mainwin != nullptr,); + if (show) + { + if (isPipeRunning()) + { + const CarlaMutexLocker cml(getPipeLock()); + writeMessage("focus\n", 6); + flushMessages(); + return; + } - uint32_t rindex = index; + carla_stdout("Trying to start UI using \"%s\"", getExtUiPath()); - if (kIsAmbisonic && index == kParameterOPMIXorRGXYZ) - rindex += 1; + CarlaExternalUI::setData(getExtUiPath(), kIsAmbisonic ? "true" : "false", getUiName()); - mainwin->_rotary[rindex]->set_value(value); + if (! CarlaExternalUI::startPipeServer(true)) + { + uiClosed(); + hostUiUnavailable(); + } + } + else + { + CarlaExternalUI::stopPipeServer(2000); + } } // ------------------------------------------------------------------- @@ -456,13 +355,7 @@ private: jack_client_t fJackClient; // Zita stuff (core) - X_resman xresman; - ScopedPointer jclient; - ScopedPointer display; - ScopedPointer rootwin; - ScopedPointer mainwin; - ScopedPointer handler; - X_handler_thread handlerThread; + ScopedPointer jclient; float fParameters[kParameterNROTARY]; @@ -492,8 +385,7 @@ static const NativePluginDescriptor rev1AmbisonicDesc = { /* hints */ static_cast(NATIVE_PLUGIN_IS_RTSAFE |NATIVE_PLUGIN_HAS_UI |NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_PARENT_ID), + |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD), /* supports */ static_cast(0x0), /* audioIns */ 2, /* audioOuts */ 4, @@ -534,8 +426,7 @@ static const NativePluginDescriptor rev1StereoDesc = { /* hints */ static_cast(NATIVE_PLUGIN_IS_RTSAFE |NATIVE_PLUGIN_HAS_UI |NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS - |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD - |NATIVE_PLUGIN_USES_PARENT_ID), + |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD), /* supports */ static_cast(0x0), /* audioIns */ 2, /* audioOuts */ 2, diff --git a/source/native-plugins/zita-rev1/global.h b/source/native-plugins/zita-rev1/global.h index d093e54ea..358e353e2 100644 --- a/source/native-plugins/zita-rev1/global.h +++ b/source/native-plugins/zita-rev1/global.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/guiclass.cc b/source/native-plugins/zita-rev1/guiclass.cc index fee626ade..c775e6c89 100644 --- a/source/native-plugins/zita-rev1/guiclass.cc +++ b/source/native-plugins/zita-rev1/guiclass.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -158,4 +158,3 @@ int Rlogctl::set_count (int u) } - diff --git a/source/native-plugins/zita-rev1/guiclass.h b/source/native-plugins/zita-rev1/guiclass.h index da4bbe9a8..788e0c5e8 100644 --- a/source/native-plugins/zita-rev1/guiclass.h +++ b/source/native-plugins/zita-rev1/guiclass.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -99,5 +99,4 @@ private: } - #endif diff --git a/source/native-plugins/zita-rev1/jclient.cc b/source/native-plugins/zita-rev1/jclient.cc index e708a2a55..26d90cc06 100644 --- a/source/native-plugins/zita-rev1/jclient.cc +++ b/source/native-plugins/zita-rev1/jclient.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -25,14 +25,13 @@ namespace REV1 { -Jclient::Jclient (const char *jname, jack_client_t *jclient, bool ambis) : +Jclient::Jclient (jack_client_t *jclient, bool ambis) : A_thread ("Jclient"), _jack_client (jclient), _active (false), - _jname (0), _ambis (ambis) { - init_jack (jname); + init_jack (); } @@ -42,16 +41,11 @@ Jclient::~Jclient (void) } -void Jclient::init_jack (const char *jname) +void Jclient::init_jack (void) { jack_set_process_callback (_jack_client, jack_static_process, (void *) this); jack_on_shutdown (_jack_client, jack_static_shutdown, (void *) this); - if (jack_activate (_jack_client)) - { - fprintf(stderr, "Can't activate JACK.\n"); - exit (1); - } - _jname = jack_get_client_name (_jack_client); + jack_activate (_jack_client); _fsamp = jack_get_sample_rate (_jack_client); _fragm = 1024; diff --git a/source/native-plugins/zita-rev1/jclient.h b/source/native-plugins/zita-rev1/jclient.h index df87481a9..74a0186ae 100644 --- a/source/native-plugins/zita-rev1/jclient.h +++ b/source/native-plugins/zita-rev1/jclient.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -36,15 +36,14 @@ class Jclient : public A_thread { public: - Jclient (const char *jname, jack_client_t *jclient, bool ambis); + Jclient (jack_client_t *jclient, bool ambis); ~Jclient (void); - const char *jname (void) const { return _jname; } Reverb *reverb (void) const { return (Reverb *) &_reverb; } private: - void init_jack (const char *jname); + void init_jack (void); void close_jack (void); void jack_shutdown (void); int jack_process (int nframes); @@ -55,7 +54,6 @@ private: jack_port_t *_inpports [2]; jack_port_t *_outports [4]; bool _active; - const char *_jname; unsigned int _fsamp; bool _ambis; int _fragm; diff --git a/source/native-plugins/zita-rev1/mainwin.cc b/source/native-plugins/zita-rev1/mainwin.cc index 64f3208db..9b5def66b 100644 --- a/source/native-plugins/zita-rev1/mainwin.cc +++ b/source/native-plugins/zita-rev1/mainwin.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -30,24 +30,21 @@ namespace REV1 { -Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient, ValueChangedCallback* valuecb) : +Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, bool ambisonic, ValueChangedCallback* valuecb) : A_thread ("Main"), X_window (parent, xp, yp, XSIZE, YSIZE, XftColors [C_MAIN_BG]->pixel), _stop (false), + _ambis (ambisonic), _xres (xres), - _jclient (jclient), _valuecb (valuecb) { X_hints H; - char s [256]; int i, x; _atom = XInternAtom (dpy (), "WM_DELETE_WINDOW", True); XSetWMProtocols (dpy (), win (), &_atom, 1); _atom = XInternAtom (dpy (), "WM_PROTOCOLS", True); - sprintf (s, "%s", jclient->jname ()); - x_set_title (s); H.position (xp, yp); H.minsize (XSIZE, YSIZE); H.maxsize (XSIZE, YSIZE); @@ -55,7 +52,7 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc H.rclas (xres->rclas ()); x_apply (&H); - _ambis = xres->getb (".ambisonic", false); + RotaryCtl::init (disp ()); x = 0; _rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY); _rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER); @@ -78,12 +75,13 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc x_add_events (ExposureMask); x_map (); set_time (0); - inc_time (250000); + inc_time (50000); } Mainwin::~Mainwin (void) { + RotaryCtl::fini (); } @@ -134,8 +132,8 @@ void Mainwin::clmesg (XClientMessageEvent *E) void Mainwin::handle_time (void) { - inc_time (500000); - XFlush (dpy ()); + inc_time (5000); + XFlush (dpy ()); } @@ -170,50 +168,41 @@ void Mainwin::handle_callb (int type, X_window *W, XEvent *E) { case R_DELAY: v = _rotary [R_DELAY]->value (); - _jclient->reverb ()->set_delay (v); _valuecb->valueChangedCallback (R_DELAY, v); break; case R_XOVER: v = _rotary [R_XOVER]->value (); - _jclient->reverb ()->set_xover (v); _valuecb->valueChangedCallback (R_XOVER, v); break; case R_RTLOW: v = _rotary [R_RTLOW]->value (); - _jclient->reverb ()->set_rtlow (v); _valuecb->valueChangedCallback (R_RTLOW, v); break; case R_RTMID: v = _rotary [R_RTMID]->value (); - _jclient->reverb ()->set_rtmid (v); _valuecb->valueChangedCallback (R_RTMID, v); break; case R_FDAMP: v = _rotary [R_FDAMP]->value (); - _jclient->reverb ()->set_fdamp (v); _valuecb->valueChangedCallback (R_FDAMP, v); break; case R_OPMIX: v = _rotary [R_OPMIX]->value (); - _jclient->reverb ()->set_opmix (v); _valuecb->valueChangedCallback (R_OPMIX, v); break; case R_RGXYZ: v = _rotary [R_RGXYZ]->value (); - _jclient->reverb ()->set_rgxyz (v); _valuecb->valueChangedCallback (R_RGXYZ, v); break; case R_EQ1FR: case R_EQ1GN: v = _rotary [R_EQ1FR]->value (), v2 = _rotary [R_EQ1GN]->value (); - _jclient->reverb ()->set_eq1 (v, v2); _valuecb->valueChangedCallback (R_EQ1FR, v); _valuecb->valueChangedCallback (R_EQ1GN, v2); break; case R_EQ2FR: case R_EQ2GN: v = _rotary [R_EQ2FR]->value (), v2 = _rotary [R_EQ2GN]->value (); - _jclient->reverb ()->set_eq2 (v, v2); _valuecb->valueChangedCallback (R_EQ2FR, v); _valuecb->valueChangedCallback (R_EQ2GN, v2); break; diff --git a/source/native-plugins/zita-rev1/mainwin.h b/source/native-plugins/zita-rev1/mainwin.h index 98f5537ad..389b4dc7e 100644 --- a/source/native-plugins/zita-rev1/mainwin.h +++ b/source/native-plugins/zita-rev1/mainwin.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -29,7 +29,7 @@ #include "jclient.h" #include "global.h" -class REV1Plugin; +class ZitaPipeClient; namespace REV1 { @@ -44,9 +44,9 @@ public: }; - enum { XSIZE = 540, YSIZE = 75 }; + enum { XSIZE = 620, YSIZE = 75 }; - Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jclient, ValueChangedCallback* valuecb); + Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, bool ambisonic, ValueChangedCallback* valuecb); ~Mainwin (void); Mainwin (const Mainwin&); Mainwin& operator=(const Mainwin&); @@ -74,12 +74,11 @@ private: bool _stop; bool _ambis; X_resman *_xres; - Jclient *_jclient; RotaryCtl *_rotary [NROTARY]; ValueChangedCallback* _valuecb; - friend class ::REV1Plugin; + friend class ::ZitaPipeClient; }; diff --git a/source/native-plugins/zita-rev1/pareq.cc b/source/native-plugins/zita-rev1/pareq.cc index 00c26c0d6..8f4be36d2 100644 --- a/source/native-plugins/zita-rev1/pareq.cc +++ b/source/native-plugins/zita-rev1/pareq.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/pareq.h b/source/native-plugins/zita-rev1/pareq.h index f74e3dc04..6216d6882 100644 --- a/source/native-plugins/zita-rev1/pareq.h +++ b/source/native-plugins/zita-rev1/pareq.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/png2img.cc b/source/native-plugins/zita-rev1/png2img.cc index 6df0c1724..2aab4c3c1 100644 --- a/source/native-plugins/zita-rev1/png2img.cc +++ b/source/native-plugins/zita-rev1/png2img.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2007-2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/png2img.h b/source/native-plugins/zita-rev1/png2img.h index ed0733b3d..7fce89db7 100644 --- a/source/native-plugins/zita-rev1/png2img.h +++ b/source/native-plugins/zita-rev1/png2img.h @@ -2,7 +2,7 @@ // // Copyright (C) 2007-2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/reverb.cc b/source/native-plugins/zita-rev1/reverb.cc index 2bf7e7e07..d4da87ed0 100644 --- a/source/native-plugins/zita-rev1/reverb.cc +++ b/source/native-plugins/zita-rev1/reverb.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2003-2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/reverb.h b/source/native-plugins/zita-rev1/reverb.h index e55cfe141..0860ccf28 100644 --- a/source/native-plugins/zita-rev1/reverb.h +++ b/source/native-plugins/zita-rev1/reverb.h @@ -2,7 +2,7 @@ // // Copyright (C) 2003-2011 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 diff --git a/source/native-plugins/zita-rev1/rotary.cc b/source/native-plugins/zita-rev1/rotary.cc index 3c6b5db06..fcd4575ca 100644 --- a/source/native-plugins/zita-rev1/rotary.cc +++ b/source/native-plugins/zita-rev1/rotary.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -28,6 +28,9 @@ namespace REV1 { +cairo_t *RotaryCtl::_cairotype = 0; +cairo_surface_t *RotaryCtl::_cairosurf = 0; + int RotaryCtl::_wb_up = 4; int RotaryCtl::_wb_dn = 5; int RotaryCtl::_keymod = 0; @@ -58,10 +61,6 @@ RotaryCtl::RotaryCtl (X_window *parent, { x_add_events ( ExposureMask | Button1MotionMask | ButtonPressMask | ButtonReleaseMask); - - _cairo->initIfNeeded(parent->disp()); - _cairotype = _cairo->type; - _cairosurf = _cairo->surf; } @@ -70,6 +69,20 @@ RotaryCtl::~RotaryCtl (void) } +void RotaryCtl::init (X_display *disp) +{ + _cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50); + _cairotype = cairo_create (_cairosurf); +} + + +void RotaryCtl::fini (void) +{ + cairo_destroy (_cairotype); + cairo_surface_destroy (_cairosurf); +} + + void RotaryCtl::handle_event (XEvent *E) { switch (E->type) diff --git a/source/native-plugins/zita-rev1/rotary.h b/source/native-plugins/zita-rev1/rotary.h index 0f0cd6bd6..d9cd57c2a 100644 --- a/source/native-plugins/zita-rev1/rotary.h +++ b/source/native-plugins/zita-rev1/rotary.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -28,7 +28,6 @@ #include #include - namespace REV1 { @@ -72,6 +71,9 @@ public: virtual void set_value (double v) = 0; virtual void get_string (char *p, int n) {} + static void init (X_display *disp); + static void fini (void); + static int _wb_up; static int _wb_dn; @@ -106,9 +108,8 @@ private: virtual int handle_motion (int dx, int dy) = 0; virtual int handle_mwheel (int dw) = 0; - juce::SharedResourcePointer _cairo; - cairo_t *_cairotype; - cairo_surface_t *_cairosurf; + static cairo_t *_cairotype; + static cairo_surface_t *_cairosurf; }; diff --git a/source/native-plugins/zita-rev1/styles.cc b/source/native-plugins/zita-rev1/styles.cc index b6f95589f..94f41e62a 100644 --- a/source/native-plugins/zita-rev1/styles.cc +++ b/source/native-plugins/zita-rev1/styles.cc @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -24,6 +24,7 @@ #include "png2img.h" #include "CarlaString.hpp" +#include namespace REV1 { @@ -47,23 +48,34 @@ RotaryImg r_opmix_img; RotaryImg r_rgxyz_img; -int styles_init (X_display *disp, X_resman *xrm, const char *resdir) +static CarlaString getResourceDir() +{ + Dl_info exeInfo; + dladdr((void*)getResourceDir, &exeInfo); + + CarlaString filename(exeInfo.dli_fname); + return filename.truncate(filename.rfind("-ui")); +} + + +void styles_init (X_display *disp, X_resman *xrm) { + CarlaString resourceDir(getResourceDir()); + XftColors [C_MAIN_BG] = disp->alloc_xftcolor (0.25f, 0.25f, 0.25f, 1.0f); XftColors [C_MAIN_FG] = disp->alloc_xftcolor (1.0f, 1.0f, 1.0f, 1.0f); - const CarlaString SHARED = CarlaString(resdir)+"/rev1"; - revsect_img = png2img (SHARED+"/revsect.png", disp, XftColors [C_MAIN_BG]); - eq1sect_img = png2img (SHARED+"/eq1sect.png", disp, XftColors [C_MAIN_BG]); - eq2sect_img = png2img (SHARED+"/eq2sect.png", disp, XftColors [C_MAIN_BG]); - mixsect_img = png2img (SHARED+"/mixsect.png", disp, XftColors [C_MAIN_BG]); - ambsect_img = png2img (SHARED+"/ambsect.png", disp, XftColors [C_MAIN_BG]); + revsect_img = png2img (resourceDir+"/revsect.png", disp, XftColors [C_MAIN_BG]); + eq1sect_img = png2img (resourceDir+"/eq1sect.png", disp, XftColors [C_MAIN_BG]); + eq2sect_img = png2img (resourceDir+"/eq2sect.png", disp, XftColors [C_MAIN_BG]); + mixsect_img = png2img (resourceDir+"/mixsect.png", disp, XftColors [C_MAIN_BG]); + ambsect_img = png2img (resourceDir+"/ambsect.png", disp, XftColors [C_MAIN_BG]); - if (!revsect_img || !mixsect_img || !ambsect_img + if (!revsect_img || !mixsect_img || !ambsect_img || !eq1sect_img || !eq2sect_img) { - fprintf (stderr, "Can't load images from '%s'.\n", SHARED.buffer()); - return 1; + fprintf (stderr, "Can't load images from '%s'.\n", resourceDir.buffer()); + exit (1); } r_delay_img._backg = XftColors [C_MAIN_BG]; @@ -164,13 +176,21 @@ int styles_init (X_display *disp, X_resman *xrm, const char *resdir) r_rgxyz_img._xref = 11.5; r_rgxyz_img._yref = 11.5; r_rgxyz_img._rad = 11; - - return 0; } void styles_fini (X_display *disp) { + revsect_img->data = 0; + mixsect_img->data = 0; + ambsect_img->data = 0; + eq1sect_img->data = 0; + eq2sect_img->data = 0; + XDestroyImage (revsect_img); + XDestroyImage (mixsect_img); + XDestroyImage (ambsect_img); + XDestroyImage (eq1sect_img); + XDestroyImage (eq2sect_img); } diff --git a/source/native-plugins/zita-rev1/styles.h b/source/native-plugins/zita-rev1/styles.h index d622108ac..dae6a9f3e 100644 --- a/source/native-plugins/zita-rev1/styles.h +++ b/source/native-plugins/zita-rev1/styles.h @@ -2,7 +2,7 @@ // // Copyright (C) 2010 Fons Adriaensen // Modified by falkTX on Jan 2015 for inclusion in Carla -// +// // 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 @@ -43,7 +43,7 @@ enum }; -extern int styles_init (X_display *disp, X_resman *xrm, const char *resdir); +extern void styles_init (X_display *disp, X_resman *xrm); extern void styles_fini (X_display *disp); extern XftColor *XftColors [NXFTCOLORS]; diff --git a/source/native-plugins/zynaddsubfx-ui.cpp b/source/native-plugins/zynaddsubfx-ui.cpp index b04fbbbe5..27e9ef14d 100644 --- a/source/native-plugins/zynaddsubfx-ui.cpp +++ b/source/native-plugins/zynaddsubfx-ui.cpp @@ -180,6 +180,7 @@ protected: } carla_stderr("ZynPipeClient::msgReceived : %s", msg); + return false; } private: