commit bc909549a8b6f831ce531037e44b166802c0af78
parent e0c0d1c2e5c4db4a944bb346a955de871cf16c15
Author: fundamental <[email protected]>
Date: Mon, 1 Aug 2016 17:22:55 -0400
Merge remote-tracking branch 'origin/zest'
Diffstat:
4 files changed, 222 insertions(+), 10 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
@@ -73,11 +73,11 @@ execute_process(COMMAND echo fistpl 0
# file, but either in in CMakeCache.txt before compile, or by passing
# parameters directly into cmake using the -D flag.
if(NTK_FOUND)
- SET (GuiModule ntk CACHE STRING "GUI module, either fltk, ntk or off")
+ SET (GuiModule ntk CACHE STRING "GUI module, either fltk, ntk, zest, or off")
elseif(FLTK_FOUND)
- SET (GuiModule fltk CACHE STRING "GUI module, either fltk, ntk or off")
+ SET (GuiModule fltk CACHE STRING "GUI module, either fltk, ntk, zest, or off")
else()
- SET (GuiModule off CACHE STRING "GUI module, either fltk, ntk or off")
+ SET (GuiModule off CACHE STRING "GUI module, either fltk, ntk, zest, or off")
endif()
SET (CompileTests ${CXXTEST_FOUND} CACHE BOOL "whether tests should be compiled in or not")
SET (AlsaEnable ${ALSA_FOUND} CACHE BOOL
@@ -152,16 +152,16 @@ endif()
-if (GuiModule STREQUAL qt AND QT_FOUND)
- set (QtGui TRUE)
-elseif(GuiModule STREQUAL ntk AND NTK_FOUND)
+if(GuiModule STREQUAL ntk AND NTK_FOUND)
set (NtkGui TRUE)
elseif(GuiModule STREQUAL fltk AND FLTK_FOUND)
set (FltkGui TRUE)
+elseif(GuiModule STREQUAL zest)
+ set (ZestGui TRUE)
elseif(GuiModule STREQUAL off)
add_definitions(-DDISABLE_GUI)
else ()
- set (GuiModule off CACHE STRING "GUI module, either fltk, qt or off")
+ set (GuiModule off CACHE STRING "GUI module, either fltk, ntk, zest, or off")
add_definitions(-DDISABLE_GUI)
message(STATUS "GUI module defaulting to off")
endif()
@@ -376,6 +376,11 @@ if(NtkGui)
add_subdirectory(UI)
endif()
+if(ZestGui)
+ add_definitions(-DHAVE_DGL)
+ add_definitions(-DZEST_GUI)
+endif()
+
if(NOT FltkGui AND NOT NtkGui)
set(NSM_WORKAROUND UI/NSM.C UI/NSM/Client.C)
add_library(zynaddsubfx_gui_bridge STATIC UI/ConnectionDummy.cpp ${NSM_WORKAROUND})
@@ -387,7 +392,7 @@ endif()
# of module-specific variables
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zyn-version.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/zyn-version.h)
+ ${CMAKE_CURRENT_SOURCE_DIR}/zyn-version.h)
link_directories(${AUDIO_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${FFTW_LIBRARY_DIRS} ${MXML_LIBRARY_DIRS} ${FLTK_LIBRARY_DIRS} ${NTK_LIBRARY_DIRS})
diff --git a/src/Plugin/ZynAddSubFX/CMakeLists.txt b/src/Plugin/ZynAddSubFX/CMakeLists.txt
@@ -1,5 +1,8 @@
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/DPF/distrho .)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/DPF/distrho .
+ ${CMAKE_SOURCE_DIR}/DPF/dgl
+ ${CMAKE_SOURCE_DIR}/DPF/dgl/src)
if(NtkGui)
@@ -42,6 +45,31 @@ add_library(ZynAddSubFX_vst SHARED
${CMAKE_SOURCE_DIR}/DPF/distrho/DistrhoPluginMain.cpp
ZynAddSubFX.cpp)
+elseif(ZestGui)
+
+# UI Enabled using Zest: internal only
+add_library(ZynAddSubFX_lv2 SHARED
+ ${CMAKE_SOURCE_DIR}/src/globals.cpp
+ ${CMAKE_SOURCE_DIR}/src/UI/ConnectionDummy.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/distrho/DistrhoPluginMain.cpp
+ ZynAddSubFX.cpp)
+
+add_library(ZynAddSubFX_lv2_ui SHARED
+ ${CMAKE_SOURCE_DIR}/DPF/distrho/DistrhoUIMain.cpp
+ ZynAddSubFX-UI-Zest.cpp)
+
+add_library(ZynAddSubFX_vst SHARED
+ ${CMAKE_SOURCE_DIR}/src/globals.cpp
+ ${CMAKE_SOURCE_DIR}/src/UI/ConnectionDummy.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/distrho/DistrhoPluginMain.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/distrho/DistrhoUIMain.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/dgl/src/Geometry.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/dgl/src/Widget.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/dgl/src/Window.cpp
+ ${CMAKE_SOURCE_DIR}/DPF/dgl/src/Application.cpp
+ ZynAddSubFX.cpp
+ ZynAddSubFX-UI-Zest.cpp)
+
else()
# UI Disabled
@@ -72,7 +100,9 @@ set_target_properties(ZynAddSubFX_vst PROPERTIES PREFIX "")
target_link_libraries(ZynAddSubFX_lv2 zynaddsubfx_core ${OS_LIBRARIES} ${LIBLO_LIBRARIES}
${PLATFORM_LIBRARIES})
target_link_libraries(ZynAddSubFX_vst zynaddsubfx_core ${OS_LIBRARIES} ${LIBLO_LIBRARIES}
- ${PLATFORM_LIBRARIES})
+ ${PLATFORM_LIBRARIES}
+ X11
+ GL)
install(TARGETS ZynAddSubFX_lv2 LIBRARY DESTINATION ${PluginLibDir}/lv2/ZynAddSubFX.lv2/)
install(TARGETS ZynAddSubFX_vst LIBRARY DESTINATION ${PluginLibDir}/vst/)
diff --git a/src/Plugin/ZynAddSubFX/DistrhoPluginInfo.h b/src/Plugin/ZynAddSubFX/DistrhoPluginInfo.h
@@ -26,6 +26,8 @@
#define DISTRHO_PLUGIN_HAS_UI 1
#define DISTRHO_PLUGIN_HAS_EMBED_UI 0
#define DISTRHO_PLUGIN_HAS_EXTERNAL_UI 1
+#elif defined(ZEST_GUI)
+ #define DISTRHO_PLUGIN_HAS_UI 1
#else
#define DISTRHO_PLUGIN_HAS_UI 0
#endif
diff --git a/src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp b/src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp
@@ -0,0 +1,175 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ ZynAddSubFX-UI.cpp - DPF + ZynAddSubFX External UI
+ Copyright (C) 2015-2016 Filipe Coelho
+ Author: 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 (at your option) any later version.
+*/
+
+// DPF includes
+#include "DistrhoUI.hpp"
+#include <dlfcn.h>
+
+typedef void *zest_t;
+struct zest_handles {
+ zest_t *(*zest_open)(const char *);
+ void (*zest_close)(zest_t*);
+ void (*zest_setup)(zest_t*);
+ void (*zest_draw)(zest_t*);
+ void (*zest_motion)(zest_t*, int x, int y);
+ void (*zest_scroll)(zest_t*, int x, int y, int dx, int dy);
+ void (*zest_mouse)(zest_t *z, int button, int action, int x, int y);
+ void (*zest_key)();
+ void (*zest_resize)();
+ int (*zest_tick)(zest_t*);
+ zest_t *zest;
+};
+
+/* ------------------------------------------------------------------------------------------------------------
+ * ZynAddSubFX UI class */
+
+class ZynAddSubFXUI : public UI
+{
+public:
+ ZynAddSubFXUI()
+ : UI(1181, 659)
+ {
+ printf("[INFO] Opened the zynaddsubfx UI...\n");
+ handle = dlopen("/home/mark/code/mruby-zest-build/libzest.so", RTLD_LAZY);
+ if(!handle) {
+ printf("[ERROR] Cannot Open libzest.so\n");
+ printf("[ERROR] '%s'\n", dlerror());
+ }
+ memset(&z, 0, sizeof(z));
+#define get_sym(x) z.zest_##x = (decltype(z.zest_##x))dlsym(handle, "zest_"#x)
+ get_sym(open);
+ get_sym(setup);
+ get_sym(close);
+ get_sym(draw);
+ get_sym(tick);
+ get_sym(motion);
+ get_sym(scroll);
+ get_sym(mouse);
+ printf("[INFO] Ready to run\n");
+ }
+
+ ~ZynAddSubFXUI() override
+ {
+ printf("[INFO:Zyn] zest_close()\n");
+ if(z.zest)
+ z.zest_close(z.zest);
+ dlclose(handle);
+ }
+
+protected:
+ /* --------------------------------------------------------------------------------------------------------
+ * DSP/Plugin Callbacks */
+
+ /**
+ A parameter has changed on the plugin side.
+ This is called by the host to inform the UI about parameter changes.
+ */
+ void parameterChanged(uint32_t index, float value) override
+ {
+ switch (index)
+ {
+ case kParamOscPort: {
+ const int port = int(value+0.5f);
+
+ if (oscPort != port)
+ {
+ oscPort = port;
+ }
+ } break;
+ }
+ }
+
+ /**
+ A program has been loaded on the plugin side.
+ This is called by the host to inform the UI about program changes.
+ */
+ void programLoaded(uint32_t index) override
+ {
+ }
+
+ /**
+ A state has changed on the plugin side.
+ This is called by the host to inform the UI about state changes.
+ */
+ void stateChanged(const char* key, const char* value) override
+ {
+ }
+
+ /* --------------------------------------------------------------------------------------------------------
+ * UI Callbacks */
+
+ bool onMouse(const MouseEvent &m) override
+ {
+ if(z.zest)
+ z.zest_mouse(z.zest, m.button, m.press, m.pos.getX(), m.pos.getY());
+ return false;
+ }
+
+ bool onMotion(const MotionEvent &m) override
+ {
+ if(z.zest)
+ z.zest_motion(z.zest, m.pos.getX(), m.pos.getY());
+ return false;
+ }
+
+ /**
+ A function called to draw the view contents with OpenGL.
+ */
+ void onDisplay() override
+ {
+ if(!z.zest) {
+ if(!z.zest_open)
+ return;
+ printf("[INFO:Zyn] zest_open()\n");
+ char address[1024];
+ snprintf(address, sizeof(address), "osc.udp://127.0.0.1:%d",oscPort);
+
+ z.zest = z.zest_open(address);
+ printf("[INFO:Zyn] zest_setup()\n");
+ z.zest_setup(z.zest);
+ }
+
+ z.zest_draw(z.zest);
+ repaint();
+ }
+
+ void uiIdle(void) override
+ {
+ if(z.zest)
+ z.zest_tick(z.zest);
+ }
+
+ void uiReshape(uint width, uint height)
+ {
+ }
+
+private:
+ int oscPort;
+ zest_handles z;
+ void *handle;
+
+
+ DISTRHO_DECLARE_NON_COPY_CLASS(ZynAddSubFXUI)
+};
+
+/* ------------------------------------------------------------------------------------------------------------
+ * Create UI, entry point */
+
+START_NAMESPACE_DISTRHO
+
+UI* createUI()
+{
+ return new ZynAddSubFXUI();
+}
+
+END_NAMESPACE_DISTRHO