1 /***************************************************************************
2 * Copyright (C) 2011 by Pere Ràfols Soler *
3 * sapista2@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 /***************************************************************************
22 This file contains some definitions of the EQ plugin UI
23 This plugin is inside the Sapista Plugins Bundle
24 ****************************************************************************/
25
26 //LV2 UI headers
27 #include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
28 #include <gtkmm/main.h>
29 #include "widgets/dynamicswindow.h"
30 #include <string>
31 #include "../plugins_uris.h"
32
33 //Testing Headers TODO: comment define TESTING_EQ10Q for the final relase
34 //#define TESTING_EQ10Q
35 #ifdef TESTING_EQ10Q
36 #include <iostream>
37 using namespace std;
38 #endif
39
instantiateDyn_gui(const LV2UI_Descriptor * descriptor,const char * plugin_uri,const char * bundle_path,LV2UI_Write_Function write_function,LV2UI_Controller controller,LV2UI_Widget * widget,const LV2_Feature * const * features)40 static LV2UI_Handle instantiateDyn_gui(const LV2UI_Descriptor *descriptor, const char *plugin_uri, const char *bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget *widget, const LV2_Feature *const *features)
41 {
42 #ifdef TESTING_EQ10Q
43 cout<<"instantiateDyn_gui Entring... ";
44 #endif
45
46 std::string sTitle;
47 bool bIsCompressor, bHasSideChain;
48 bool bAllOk = false;
49
50 std::string str_plugin_uri(plugin_uri);
51 if( str_plugin_uri == GATE_MONO_URI || str_plugin_uri == GATE_STEREO_URI)
52 {
53 sTitle = "GT10Q ~ Noise Gate";
54 bIsCompressor = false;
55 bHasSideChain = false;
56 bAllOk = true;
57 }
58 if( str_plugin_uri == COMPRESSOR_MONO_URI || str_plugin_uri == COMPRESSOR_STEREO_URI)
59 {
60 sTitle = "CS10Q ~ Compressor";
61 bIsCompressor = true;
62 bHasSideChain = false;
63 bAllOk = true;
64 }
65 if( str_plugin_uri == COMPRESSOR_SC_MONO_URI || str_plugin_uri == COMPRESSOR_SC_STEREO_URI)
66 {
67 sTitle = "CS10Q-SC ~ Side-Chain Compressor";
68 bIsCompressor = true;
69 bHasSideChain = true;
70 bAllOk = true;
71 }
72 if(! bAllOk)
73 {
74 return NULL;
75 }
76
77 Gtk::Main::init_gtkmm_internals();
78 DynMainWindow* gui_data = new DynMainWindow(plugin_uri, std::string(bundle_path), sTitle, bIsCompressor, bHasSideChain);
79 gui_data->controller = controller;
80 gui_data->write_function = write_function;
81 *widget = gui_data->gobj();
82
83 #ifdef TESTING_EQ10Q
84 cout<<" Done"<<endl;
85 #endif
86
87 return (LV2UI_Handle)gui_data;
88 }
89
90
cleanupDyn_gui(LV2UI_Handle instance)91 static void cleanupDyn_gui(LV2UI_Handle instance)
92 {
93 #ifdef TESTING_EQ10Q
94 cout<<"cleanupEq10q_gui Entring... ";
95 #endif
96
97 ///delete static_cast<DynMainWindow*>(instance);
98 DynMainWindow *gui = (DynMainWindow *)instance;
99 delete gui;
100
101 #ifdef TESTING_EQ10Q
102 cout<<" Done"<<endl;
103 #endif
104 }
105
portEventDyn_gui(LV2UI_Handle ui,uint32_t port_index,uint32_t buffer_size,uint32_t format,const void * buffer)106 static void portEventDyn_gui(LV2UI_Handle ui, uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer)
107 {
108 #ifdef TESTING_EQ10Q
109 cout<<"portEventEq10q_gui Entring... "<<"Port Index = "<<port_index;
110 #endif
111
112 DynMainWindow *gui = (DynMainWindow *)ui;
113 gui->gui_port_event(ui, port_index, buffer_size, format, buffer);
114
115 #ifdef TESTING_EQ10Q
116 cout<<" Done"<<endl;
117 #endif
118 }
119
120 static const LV2UI_Descriptor dyn_guiDescriptor = {
121 DYNAMICS_GUI_URI,
122 instantiateDyn_gui,
123 cleanupDyn_gui,
124 portEventDyn_gui,
125 NULL
126 };
127
128 LV2_SYMBOL_EXPORT
lv2ui_descriptor(uint32_t index)129 const LV2UI_Descriptor *lv2ui_descriptor(uint32_t index)
130 {
131 #ifdef TESTING_EQ10Q
132 cout<<"lv2ui_descriptor Entring... ";
133 #endif
134
135 switch (index) {
136 case 0:
137 #ifdef TESTING_EQ10Q
138 cout<<" Done with OK result (return LV2UI_Descriptor)"<<endl;
139 #endif
140 return &dyn_guiDescriptor;
141 default:
142 #ifdef TESTING_EQ10Q
143 cout<<" Done with NOK result (return NULL)"<<endl;
144 #endif
145 return NULL;
146 }
147
148
149 }
150