2 ZynAddSubFX - a software synthesizer
4 ZynAddSubFX-UI.cpp - DPF + ZynAddSubFX External UI
5 Copyright (C) 2015-2016 Filipe Coelho
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
15 #include "DistrhoUI.hpp"
20 zest_t
*(*zest_open
)(const char *);
21 void (*zest_close
)(zest_t
*);
22 void (*zest_setup
)(zest_t
*);
23 void (*zest_draw
)(zest_t
*);
24 void (*zest_motion
)(zest_t
*, int x
, int y
);
25 void (*zest_scroll
)(zest_t
*, int x
, int y
, int dx
, int dy
);
26 void (*zest_mouse
)(zest_t
*z
, int button
, int action
, int x
, int y
);
27 void (*zest_key
)(zest_t
*z
, char *key
, bool press
);
28 void (*zest_resize
)();
29 void (*zest_special
)(zest_t
*z
, int key
, int press
);
30 int (*zest_tick
)(zest_t
*);
34 /* ------------------------------------------------------------------------------------------------------------
35 * ZynAddSubFX UI class */
37 class ZynAddSubFXUI
: public UI
43 printf("[INFO] Opened the zynaddsubfx UI...\n");
44 handle
= dlopen("/opt/zyn-fusion/libzest.so", RTLD_LAZY
);
46 printf("[ERROR] Cannot Open libzest.so\n");
47 printf("[ERROR] '%s'\n", dlerror());
49 memset(&z
, 0, sizeof(z
));
50 #define get_sym(x) z.zest_##x = (decltype(z.zest_##x))dlsym(handle, "zest_"#x)
64 printf("[INFO] Ready to run\n");
67 ~ZynAddSubFXUI() override
69 printf("[INFO:Zyn] zest_close()\n");
77 /* --------------------------------------------------------------------------------------------------------
78 * DSP/Plugin Callbacks */
81 A parameter has changed on the plugin side.
82 This is called by the host to inform the UI about parameter changes.
84 void parameterChanged(uint32_t index
, float value
) override
89 const int port
= int(value
+0.5f
);
100 A program has been loaded on the plugin side.
101 This is called by the host to inform the UI about program changes.
103 void programLoaded(uint32_t index
) override
108 A state has changed on the plugin side.
109 This is called by the host to inform the UI about state changes.
111 void stateChanged(const char* key
, const char* value
) override
115 /* --------------------------------------------------------------------------------------------------------
118 bool onScroll(const ScrollEvent
&ev
) override
121 z
.zest_scroll(z
.zest
, ev
.pos
.getX(), ev
.pos
.getY(), ev
.delta
.getX(), ev
.delta
.getY());
125 bool onSpecial(const SpecialEvent
&ev
) override
127 printf("special event = %d, %d\n", ev
.key
, ev
.press
);
129 z
.zest_special(z
.zest
, ev
.key
, ev
.press
);
133 bool onMouse(const MouseEvent
&m
) override
136 z
.zest_mouse(z
.zest
, m
.button
, m
.press
, m
.pos
.getX(), m
.pos
.getY());
140 bool onMotion(const MotionEvent
&m
) override
143 z
.zest_motion(z
.zest
, m
.pos
.getX(), m
.pos
.getY());
148 A function called to draw the view contents with OpenGL.
150 void onDisplay() override
157 //printf("[INFO:Zyn] zest_open()\n");
159 snprintf(address
, sizeof(address
), "osc.udp://127.0.0.1:%d",oscPort
);
160 printf("[INFO:Zyn] zest_open(%s)\n", address
);
162 z
.zest
= z
.zest_open(address
);
163 printf("[INFO:Zyn] zest_setup()\n");
164 z
.zest_setup(z
.zest
);
171 bool onKeyboard(const KeyboardEvent
&ev
)
177 z
.zest_key(z
.zest
, c
, ev
.press
);
181 void uiIdle(void) override
187 void uiReshape(uint width
, uint height
)
197 DISTRHO_DECLARE_NON_COPY_CLASS(ZynAddSubFXUI
)
200 /* ------------------------------------------------------------------------------------------------------------
201 * Create UI, entry point */
203 START_NAMESPACE_DISTRHO
207 return new ZynAddSubFXUI();
210 END_NAMESPACE_DISTRHO