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/eqwindow.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
40
instantiateEq10q_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 static LV2UI_Handle instantiateEq10q_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)
42 {
43 #ifdef TESTING_EQ10Q
44 cout<<"instantiateEq10q_gui Entring... ";
45 cout<<endl<<"Plguins URI:"<<plugin_uri;
46 #endif
47
48 int nChannels = 0;
49 int nBands = 0;
50 std::string str_plugin_uri(plugin_uri);
51 if( str_plugin_uri == EQ1QM_URI)
52 {
53 nChannels = 1;
54 nBands = 1;
55 }
56 if( str_plugin_uri == EQ1QS_URI)
57 {
58 nChannels = 2;
59 nBands = 1;
60 }
61 if( str_plugin_uri == EQ4QM_URI)
62 {
63 nChannels = 1;
64 nBands = 4;
65 }
66 if( str_plugin_uri == EQ4QS_URI)
67 {
68 nChannels = 2;
69 nBands = 4;
70 }
71 if( str_plugin_uri == EQ6QM_URI)
72 {
73 nChannels = 1;
74 nBands = 6;
75 }
76 if( str_plugin_uri == EQ6QS_URI)
77 {
78 nChannels = 2;
79 nBands = 6;
80 }
81 if( str_plugin_uri == EQ10QM_URI)
82 {
83 nChannels = 1;
84 nBands = 10;
85 }
86 if( str_plugin_uri == EQ10QS_URI)
87 {
88 nChannels = 2;
89 nBands = 10;
90 }
91 #ifdef TESTING_EQ10Q
92 cout<<"\nChannels = "<< nChannels<<"\tnBands = "<< nBands;
93 #endif
94 if(nChannels == 0)
95 {
96 return NULL;
97 }
98 if(nBands == 0)
99 {
100 return NULL;
101 }
102
103 Gtk::Main::init_gtkmm_internals();
104 EqMainWindow* gui_data = new EqMainWindow( nChannels, nBands, plugin_uri, bundle_path, features);
105 gui_data->controller = controller;
106 gui_data->write_function = write_function;
107 *widget = gui_data->gobj();
108
109 //Get sample rate from DSP
110 gui_data->request_sample_rate();
111
112 #ifdef TESTING_EQ10Q
113 cout<<" Done"<<endl;
114 #endif
115
116 return (LV2UI_Handle)gui_data;
117 }
118
119
cleanupEq10q_gui(LV2UI_Handle instance)120 static void cleanupEq10q_gui(LV2UI_Handle instance)
121 {
122 #ifdef TESTING_EQ10Q
123 cout<<"cleanupEq10q_gui Entring... ";
124 #endif
125
126 ///delete static_cast<EqMainWindow*>(instance);
127 EqMainWindow *gui = (EqMainWindow *)instance;
128 delete gui;
129
130 #ifdef TESTING_EQ10Q
131 cout<<" Done"<<endl;
132 #endif
133 }
134
portEventEq10q_gui(LV2UI_Handle ui,uint32_t port_index,uint32_t buffer_size,uint32_t format,const void * buffer)135 static void portEventEq10q_gui(LV2UI_Handle ui, uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer)
136 {
137 #ifdef TESTING_EQ10Q
138 cout<<"portEventEq10q_gui Entring... "<<"Port Index = "<<port_index;
139 #endif
140
141 EqMainWindow *gui = (EqMainWindow *)ui;
142 gui->gui_port_event(ui, port_index, buffer_size, format, buffer);
143
144 #ifdef TESTING_EQ10Q
145 cout<<" Done"<<endl;
146 #endif
147 }
148
149
150 static const LV2UI_Descriptor eq10q_guiDescriptor = {
151 EQ10Q_GUI_URI,
152 instantiateEq10q_gui,
153 cleanupEq10q_gui,
154 portEventEq10q_gui,
155 NULL
156 };
157
158
159 LV2_SYMBOL_EXPORT
lv2ui_descriptor(uint32_t index)160 const LV2UI_Descriptor *lv2ui_descriptor(uint32_t index)
161 {
162 #ifdef TESTING_EQ10Q
163 cout<<"lv2ui_descriptor Entring... ";
164 #endif
165
166 switch (index) {
167 case 0:
168 #ifdef TESTING_EQ10Q
169 cout<<" Done with OK result (return LV2UI_Descriptor)"<<endl;
170 #endif
171 return &eq10q_guiDescriptor;
172 default:
173 #ifdef TESTING_EQ10Q
174 cout<<" Done with NOK result (return NULL)"<<endl;
175 #endif
176 return NULL;
177 }
178
179
180 }
181
182
183