4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcdisplayinfo.h"
24 #include "bcsignals.h"
25 #include "filesystem.h"
28 #include "reverbwindow.h"
34 ReverbWindow::ReverbWindow(Reverb *reverb)
35 : PluginClientWindow(reverb,
42 this->reverb = reverb;
45 ReverbWindow::~ReverbWindow()
49 void ReverbWindow::create_objects()
52 add_tool(new BC_Title(5, y + 10, _("Initial signal level:")));
53 add_tool(level_init = new ReverbLevelInit(reverb, x, y)); y += 25;
54 add_tool(new BC_Title(5, y + 10, _("ms before reflections:")));
55 add_tool(delay_init = new ReverbDelayInit(reverb, x + 35, y)); y += 25;
56 add_tool(new BC_Title(5, y + 10, _("First reflection level:")));
57 add_tool(ref_level1 = new ReverbRefLevel1(reverb, x, y)); y += 25;
58 add_tool(new BC_Title(5, y + 10, _("Last reflection level:")));
59 add_tool(ref_level2 = new ReverbRefLevel2(reverb, x + 35, y)); y += 25;
60 add_tool(new BC_Title(5, y + 10, _("Number of reflections:")));
61 add_tool(ref_total = new ReverbRefTotal(reverb, x, y)); y += 25;
62 add_tool(new BC_Title(5, y + 10, _("ms of reflections:")));
63 add_tool(ref_length = new ReverbRefLength(reverb, x + 35, y)); y += 25;
64 add_tool(new BC_Title(5, y + 10, _("Start band for lowpass:")));
65 add_tool(lowpass1 = new ReverbLowPass1(reverb, x, y)); y += 25;
66 add_tool(new BC_Title(5, y + 10, _("End band for lowpass:")));
67 add_tool(lowpass2 = new ReverbLowPass2(reverb, x + 35, y)); y += 40;
77 ReverbLevelInit::ReverbLevelInit(Reverb *reverb, int x, int y)
80 reverb->config.level_init,
84 this->reverb = reverb;
86 ReverbLevelInit::~ReverbLevelInit()
89 int ReverbLevelInit::handle_event()
91 //printf("ReverbLevelInit::handle_event 1 %p\n", reverb);
92 reverb->config.level_init = get_value();
93 //printf("ReverbLevelInit::handle_event 1\n");
94 reverb->send_configure_change();
95 //printf("ReverbLevelInit::handle_event 2\n");
99 ReverbDelayInit::ReverbDelayInit(Reverb *reverb, int x, int y)
102 reverb->config.delay_init,
106 this->reverb = reverb;
108 ReverbDelayInit::~ReverbDelayInit()
111 int ReverbDelayInit::handle_event()
113 reverb->config.delay_init = get_value();
114 reverb->send_configure_change();
118 ReverbRefLevel1::ReverbRefLevel1(Reverb *reverb, int x, int y)
121 reverb->config.ref_level1,
125 this->reverb = reverb;
127 ReverbRefLevel1::~ReverbRefLevel1() {}
128 int ReverbRefLevel1::handle_event()
130 reverb->config.ref_level1 = get_value();
131 reverb->send_configure_change();
136 ReverbRefLevel2::ReverbRefLevel2(Reverb *reverb, int x, int y)
139 reverb->config.ref_level2,
143 this->reverb = reverb;
145 ReverbRefLevel2::~ReverbRefLevel2() {}
146 int ReverbRefLevel2::handle_event()
148 reverb->config.ref_level2 = get_value();
149 reverb->send_configure_change();
153 ReverbRefTotal::ReverbRefTotal(Reverb *reverb, int x, int y)
156 reverb->config.ref_total,
160 this->reverb = reverb;
162 ReverbRefTotal::~ReverbRefTotal() {}
163 int ReverbRefTotal::handle_event()
165 reverb->config.ref_total = get_value();
166 reverb->send_configure_change();
171 ReverbRefLength::ReverbRefLength(Reverb *reverb, int x, int y)
174 reverb->config.ref_length,
178 this->reverb = reverb;
180 ReverbRefLength::~ReverbRefLength() {}
181 int ReverbRefLength::handle_event()
183 reverb->config.ref_length = get_value();
184 reverb->send_configure_change();
188 ReverbLowPass1::ReverbLowPass1(Reverb *reverb, int x, int y)
191 reverb->config.lowpass1)
193 this->reverb = reverb;
195 ReverbLowPass1::~ReverbLowPass1() {}
196 int ReverbLowPass1::handle_event()
198 reverb->config.lowpass1 = get_value();
199 reverb->send_configure_change();
203 ReverbLowPass2::ReverbLowPass2(Reverb *reverb, int x, int y)
206 reverb->config.lowpass2)
208 this->reverb = reverb;
210 ReverbLowPass2::~ReverbLowPass2() {}
211 int ReverbLowPass2::handle_event()
213 reverb->config.lowpass2 = get_value();
214 reverb->send_configure_change();
218 // ReverbMenu::ReverbMenu(Reverb *reverb, ReverbWindow *window)
219 // : BC_MenuBar(0, 0, window->get_w())
221 // this->window = window;
222 // this->reverb = reverb;
225 // ReverbMenu::~ReverbMenu()
229 // //delete set_default;
230 // for(int i = 0; i < total_loads; i++)
232 // delete prev_load[i];
234 // delete prev_load_thread;
237 // void ReverbMenu::create_objects(BC_Hash *defaults)
239 // add_menu(filemenu = new BC_Menu(_("File")));
240 // filemenu->add_item(load = new ReverbLoad(reverb, this));
241 // filemenu->add_item(save = new ReverbSave(reverb, this));
242 // //filemenu->add_item(set_default = new ReverbSetDefault);
243 // load_defaults(defaults);
244 // prev_load_thread = new ReverbLoadPrevThread(reverb, this);
247 // int ReverbMenu::load_defaults(BC_Hash *defaults)
250 // total_loads = defaults->get("TOTAL_LOADS", 0);
251 // if(total_loads > 0)
253 // filemenu->add_item(new BC_MenuItem("-"));
254 // char string[1024], path[1024], filename[1024];
256 // for(int i = 0; i < total_loads; i++)
258 // sprintf(string, "LOADPREVIOUS%d", i);
259 // defaults->get(string, path);
260 // fs.extract_name(filename, path);
261 // //printf("ReverbMenu::load_defaults %s\n", path);
262 // filemenu->add_item(prev_load[i] = new ReverbLoadPrev(reverb, this, filename, path));
268 // int ReverbMenu::save_defaults(BC_Hash *defaults)
270 // if(total_loads > 0)
272 // defaults->update("TOTAL_LOADS", total_loads);
273 // char string[1024];
275 // for(int i = 0; i < total_loads; i++)
277 // sprintf(string, "LOADPREVIOUS%d", i);
278 // defaults->update(string, prev_load[i]->path);
284 // int ReverbMenu::add_load(char *path)
286 // if(total_loads == 0)
288 // filemenu->add_item(new BC_MenuItem("-"));
291 // // test for existing copy
293 // char text[1024], new_path[1024]; // get text and path
294 // fs.extract_name(text, path);
295 // strcpy(new_path, path);
297 // for(int i = 0; i < total_loads; i++)
299 // if(!strcmp(prev_load[i]->get_text(), text)) // already exists
300 // { // swap for top load
301 // for(int j = i; j > 0; j--) // move preceeding loads down
303 // prev_load[j]->set_text(prev_load[j - 1]->get_text());
304 // prev_load[j]->set_path(prev_load[j - 1]->path);
306 // prev_load[0]->set_text(text);
307 // prev_load[0]->set_path(new_path);
312 // // add another load
313 // if(total_loads < TOTAL_LOADS)
315 // filemenu->add_item(prev_load[total_loads] = new ReverbLoadPrev(reverb, this));
319 // // cycle loads down
320 // for(int i = total_loads - 1; i > 0; i--)
322 // // set menu item text
323 // prev_load[i]->set_text(prev_load[i - 1]->get_text());
325 // prev_load[i]->set_path(prev_load[i - 1]->path);
328 // // set up the new load
329 // prev_load[0]->set_text(text);
330 // prev_load[0]->set_path(new_path);
334 // ReverbLoad::ReverbLoad(Reverb *reverb, ReverbMenu *menu)
335 // : BC_MenuItem(_("Load..."))
337 // this->reverb = reverb;
338 // this->menu = menu;
339 // thread = new ReverbLoadThread(reverb, menu);
341 // ReverbLoad::~ReverbLoad()
345 // int ReverbLoad::handle_event()
351 // ReverbSave::ReverbSave(Reverb *reverb, ReverbMenu *menu)
352 // : BC_MenuItem(_("Save..."))
354 // this->reverb = reverb;
355 // this->menu = menu;
356 // thread = new ReverbSaveThread(reverb, menu);
358 // ReverbSave::~ReverbSave()
362 // int ReverbSave::handle_event()
368 // ReverbSetDefault::ReverbSetDefault()
369 // : BC_MenuItem(_("Set default"))
372 // int ReverbSetDefault::handle_event()
377 // ReverbLoadPrev::ReverbLoadPrev(Reverb *reverb, ReverbMenu *menu, char *filename, char *path)
378 // : BC_MenuItem(filename)
380 // this->reverb = reverb;
381 // this->menu = menu;
382 // strcpy(this->path, path);
384 // ReverbLoadPrev::ReverbLoadPrev(Reverb *reverb, ReverbMenu *menu)
387 // this->reverb = reverb;
388 // this->menu = menu;
390 // int ReverbLoadPrev::handle_event()
392 // menu->prev_load_thread->set_path(path);
393 // menu->prev_load_thread->start();
395 // int ReverbLoadPrev::set_path(char *path)
397 // strcpy(this->path, path);
401 // ReverbSaveThread::ReverbSaveThread(Reverb *reverb, ReverbMenu *menu)
404 // this->reverb = reverb;
405 // this->menu = menu;
407 // ReverbSaveThread::~ReverbSaveThread()
410 // void ReverbSaveThread::run()
414 // ReverbSaveDialog dialog(reverb);
415 // dialog.create_objects();
416 // result = dialog.run_window();
417 // // if(!result) strcpy(reverb->config_directory, dialog.get_path());
421 // result = reverb->save_to_file(reverb->config_directory);
422 // menu->add_load(reverb->config_directory);
426 // ReverbSaveDialog::ReverbSaveDialog(Reverb *reverb)
429 // reverb->config_directory,
431 // _("Select the reverb file to save as"), 0, 0)
433 // this->reverb = reverb;
435 // ReverbSaveDialog::~ReverbSaveDialog()
438 // int ReverbSaveDialog::ok_event()
443 // int ReverbSaveDialog::cancel_event()
451 // ReverbLoadThread::ReverbLoadThread(Reverb *reverb, ReverbMenu *menu)
454 // this->reverb = reverb;
455 // this->menu = menu;
457 // ReverbLoadThread::~ReverbLoadThread()
460 // void ReverbLoadThread::run()
464 // ReverbLoadDialog dialog(reverb);
465 // dialog.create_objects();
466 // result = dialog.run_window();
467 // // if(!result) strcpy(reverb->config_directory, dialog.get_path());
471 // result = reverb->load_from_file(reverb->config_directory);
474 // menu->add_load(reverb->config_directory);
475 // reverb->send_configure_change();
480 // ReverbLoadPrevThread::ReverbLoadPrevThread(Reverb *reverb, ReverbMenu *menu) : Thread()
482 // this->reverb = reverb;
483 // this->menu = menu;
485 // ReverbLoadPrevThread::~ReverbLoadPrevThread()
488 // void ReverbLoadPrevThread::run()
491 // strcpy(reverb->config_directory, path);
492 // result = reverb->load_from_file(path);
495 // menu->add_load(path);
496 // reverb->send_configure_change();
499 // int ReverbLoadPrevThread::set_path(char *path)
501 // strcpy(this->path, path);
509 // ReverbLoadDialog::ReverbLoadDialog(Reverb *reverb)
512 // reverb->config_directory,
514 // _("Select the reverb file to load from"), 0, 0)
516 // this->reverb = reverb;
518 // ReverbLoadDialog::~ReverbLoadDialog()
521 // int ReverbLoadDialog::ok_event()
526 // int ReverbLoadDialog::cancel_event()