00001 #include "clip.h"
00002 #include "data/lad_picon_png.h"
00003 #include "defaults.h"
00004 #include "filexml.h"
00005 #include "pluginaclientlad.h"
00006 #include "pluginserver.h"
00007 #include "vframe.h"
00008
00009 #include <ctype.h>
00010 #include <string.h>
00011
00012 #include <libintl.h>
00013 #define _(String) gettext(String)
00014 #define gettext_noop(String) String
00015 #define N_(String) gettext_noop (String)
00016
00017
00018
00019 PluginAClientConfig::PluginAClientConfig()
00020 {
00021 reset();
00022 }
00023
00024 PluginAClientConfig::~PluginAClientConfig()
00025 {
00026 delete_objects();
00027 }
00028
00029 void PluginAClientConfig::reset()
00030 {
00031 total_ports = 0;
00032 port_data = 0;
00033 port_type = 0;
00034 }
00035
00036 void PluginAClientConfig::delete_objects()
00037 {
00038 if(port_data)
00039 delete [] port_data;
00040 if(port_type)
00041 delete [] port_type;
00042 reset();
00043 }
00044
00045
00046 int PluginAClientConfig::equivalent(PluginAClientConfig &that)
00047 {
00048 if(that.total_ports != total_ports) return 0;
00049 for(int i = 0; i < total_ports; i++)
00050 if(!EQUIV(port_data[i], that.port_data[i])) return 0;
00051 return 1;
00052 }
00053
00054
00055 void PluginAClientConfig::copy_from(PluginAClientConfig &that)
00056 {
00057 if(total_ports != that.total_ports)
00058 {
00059 delete_objects();
00060 total_ports = that.total_ports;
00061 port_data = new LADSPA_Data[total_ports];
00062 port_type = new int[total_ports];
00063 }
00064
00065 for(int i = 0; i < total_ports; i++)
00066 {
00067 port_type[i] = that.port_type[i];
00068 port_data[i] = that.port_data[i];
00069
00070 }
00071
00072 }
00073
00074 void PluginAClientConfig::interpolate(PluginAClientConfig &prev,
00075 PluginAClientConfig &next,
00076 int64_t prev_frame,
00077 int64_t next_frame,
00078 int64_t current_frame)
00079 {
00080 copy_from(prev);
00081 }
00082
00083 void PluginAClientConfig::initialize(PluginServer *server)
00084 {
00085 delete_objects();
00086
00087 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00088 {
00089 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00090 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00091 {
00092 total_ports++;
00093 }
00094 }
00095
00096 port_data = new LADSPA_Data[total_ports];
00097 port_type = new int[total_ports];
00098
00099 int current_port = 0;
00100 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00101 {
00102 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00103 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00104 {
00105
00106 float value = 0.0;
00107 const LADSPA_PortRangeHint *lad_hint = &server->lad_descriptor->PortRangeHints[i];
00108 LADSPA_PortRangeHintDescriptor hint_desc = lad_hint->HintDescriptor;
00109
00110
00111 port_type[current_port] = PORT_NORMAL;
00112 if(LADSPA_IS_HINT_SAMPLE_RATE(hint_desc))
00113
00114
00115 {
00116
00117 port_type[current_port] = PORT_FREQ_INDEX;
00118 }
00119 else
00120 if(LADSPA_IS_HINT_TOGGLED(hint_desc))
00121 port_type[current_port] = PORT_TOGGLE;
00122 else
00123 if(LADSPA_IS_HINT_INTEGER(hint_desc))
00124 port_type[current_port] = PORT_INTEGER;
00125
00126
00127
00128
00129
00130
00131
00132 if(LADSPA_IS_HINT_DEFAULT_0(hint_desc))
00133 value = 0.0;
00134 else
00135 if(LADSPA_IS_HINT_DEFAULT_1(hint_desc))
00136 value = 1.0;
00137 else
00138 if(LADSPA_IS_HINT_DEFAULT_100(hint_desc))
00139 value = 100.0;
00140 else
00141 if(LADSPA_IS_HINT_DEFAULT_440(hint_desc))
00142 {
00143 if(port_type[current_port] == PORT_FREQ_INDEX)
00144 value = 440.0 / 44100;
00145 else
00146 value = 440.0;
00147 }
00148 else
00149 if(LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_desc))
00150 value = lad_hint->UpperBound;
00151 else
00152 if(LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_desc))
00153 value = lad_hint->LowerBound;
00154 else
00155 if(LADSPA_IS_HINT_DEFAULT_LOW(hint_desc))
00156 {
00157 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
00158 value = exp(log(lad_hint->LowerBound) * 0.25 +
00159 log(lad_hint->UpperBound) * 0.75);
00160 else
00161 value = lad_hint->LowerBound * 0.25 +
00162 lad_hint->UpperBound * 0.75;
00163 }
00164 else
00165 if(LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_desc))
00166 {
00167 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
00168 value = exp(log(lad_hint->LowerBound) * 0.5 +
00169 log(lad_hint->UpperBound) * 0.5);
00170 else
00171 value = lad_hint->LowerBound * 0.5 +
00172 lad_hint->UpperBound * 0.5;
00173 }
00174 else
00175 if(LADSPA_IS_HINT_DEFAULT_HIGH(hint_desc))
00176 {
00177 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
00178 value = exp(log(lad_hint->LowerBound) * 0.75 +
00179 log(lad_hint->UpperBound) * 0.25);
00180 else
00181 value = lad_hint->LowerBound * 0.75 +
00182 lad_hint->UpperBound * 0.25;
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 port_data[current_port] = value;
00194 current_port++;
00195 }
00196 }
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 PluginACLientToggle::PluginACLientToggle(PluginAClientLAD *plugin,
00210 int x,
00211 int y,
00212 LADSPA_Data *output)
00213 : BC_CheckBox(x, y, (int)(*output))
00214 {
00215 this->plugin = plugin;
00216 this->output = output;
00217 }
00218
00219 int PluginACLientToggle::handle_event()
00220 {
00221 *output = get_value();
00222 plugin->send_configure_change();
00223 return 1;
00224 }
00225
00226
00227
00228
00229
00230
00231
00232 PluginACLientILinear::PluginACLientILinear(PluginAClientLAD *plugin,
00233 int x,
00234 int y,
00235 LADSPA_Data *output,
00236 int min,
00237 int max)
00238 : BC_IPot(x, y, (int)(*output), min, max)
00239 {
00240 this->plugin = plugin;
00241 this->output = output;
00242 }
00243
00244 int PluginACLientILinear::handle_event()
00245 {
00246 *output = get_value();
00247 plugin->send_configure_change();
00248 return 1;
00249 }
00250
00251
00252
00253
00254
00255
00256 PluginACLientFLinear::PluginACLientFLinear(PluginAClientLAD *plugin,
00257 int x,
00258 int y,
00259 LADSPA_Data *output,
00260 float min,
00261 float max)
00262 : BC_FPot(x, y, *output, min, max)
00263 {
00264 this->plugin = plugin;
00265 this->output = output;
00266 set_precision(0.01);
00267 }
00268
00269 int PluginACLientFLinear::handle_event()
00270 {
00271 *output = get_value();
00272 plugin->send_configure_change();
00273 return 1;
00274 }
00275
00276
00277
00278
00279
00280
00281
00282 PluginACLientFreq::PluginACLientFreq(PluginAClientLAD *plugin,
00283 int x,
00284 int y,
00285 LADSPA_Data *output,
00286 int translate_linear)
00287 : BC_QPot(x,
00288 y,
00289 translate_linear ?
00290 (int)(*output * plugin->PluginAClient::project_sample_rate) :
00291 (int)*output)
00292 {
00293
00294 this->plugin = plugin;
00295 this->output = output;
00296 this->translate_linear = translate_linear;
00297 }
00298
00299 int PluginACLientFreq::handle_event()
00300 {
00301 *output = translate_linear ?
00302 (float)get_value() / plugin->PluginAClient::project_sample_rate :
00303 get_value();
00304
00305 plugin->send_configure_change();
00306 return 1;
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317 PluginAClientWindow::PluginAClientWindow(PluginAClientLAD *plugin,
00318 int x,
00319 int y)
00320 : BC_Window(plugin->gui_string,
00321 x,
00322 y,
00323 500,
00324 plugin->config.total_ports * 30 + 60,
00325 500,
00326 plugin->config.total_ports * 30 + 60,
00327 0,
00328 1)
00329 {
00330 this->plugin = plugin;
00331 }
00332
00333 PluginAClientWindow::~PluginAClientWindow()
00334 {
00335 }
00336
00337
00338 int PluginAClientWindow::create_objects()
00339 {
00340 PluginServer *server = plugin->server;
00341 char string[BCTEXTLEN];
00342 int current_port = 0;
00343 int x = 10;
00344 int y = 10;
00345 int x2 = 300;
00346 int x3 = 335;
00347 int title_vmargin = 5;
00348 int max_w = 0;
00349 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00350 {
00351 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00352 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00353 {
00354 int w = get_text_width(MEDIUMFONT, (char*)server->lad_descriptor->PortNames[i]);
00355 if(w > max_w) max_w = w;
00356 }
00357 }
00358
00359 x2 = max_w + 20;
00360 x3 = max_w + 55;
00361 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00362 {
00363 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00364 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00365 {
00366 const LADSPA_PortRangeHint *lad_hint = &server->lad_descriptor->PortRangeHints[i];
00367 LADSPA_PortRangeHintDescriptor hint_desc = lad_hint->HintDescriptor;
00368 int use_min = LADSPA_IS_HINT_BOUNDED_BELOW(hint_desc);
00369 int use_max = LADSPA_IS_HINT_BOUNDED_ABOVE(hint_desc);
00370 sprintf(string, "%s:", server->lad_descriptor->PortNames[i]);
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380 switch(plugin->config.port_type[current_port])
00381 {
00382 case PluginAClientConfig::PORT_NORMAL:
00383 {
00384 PluginACLientFLinear *flinear;
00385 float min = use_min ? lad_hint->LowerBound : 0;
00386 float max = use_max ? lad_hint->UpperBound : 100;
00387 add_subwindow(new BC_Title(x,
00388 y + title_vmargin,
00389 string));
00390 add_subwindow(flinear = new PluginACLientFLinear(
00391 plugin,
00392 (current_port % 2) ? x2 : x3,
00393 y,
00394 &plugin->config.port_data[current_port],
00395 min,
00396 max));
00397 fpots.append(flinear);
00398 break;
00399 }
00400 case PluginAClientConfig::PORT_FREQ_INDEX:
00401 {
00402 PluginACLientFreq *freq;
00403 add_subwindow(new BC_Title(x,
00404 y + title_vmargin,
00405 string));
00406 add_subwindow(freq = new PluginACLientFreq(
00407 plugin,
00408 (current_port % 2) ? x2 : x3,
00409 y,
00410 &plugin->config.port_data[current_port],
00411 0
00412
00413
00414 ));
00415 freqs.append(freq);
00416 break;
00417 }
00418 case PluginAClientConfig::PORT_TOGGLE:
00419 {
00420 PluginACLientToggle *toggle;
00421 add_subwindow(new BC_Title(x,
00422 y + title_vmargin,
00423 string));
00424 add_subwindow(toggle = new PluginACLientToggle(
00425 plugin,
00426 (current_port % 2) ? x2 : x3,
00427 y,
00428 &plugin->config.port_data[current_port]));
00429 toggles.append(toggle);
00430 break;
00431 }
00432 case PluginAClientConfig::PORT_INTEGER:
00433 {
00434 PluginACLientILinear *ilinear;
00435 float min = use_min ? lad_hint->LowerBound : 0;
00436 float max = use_max ? lad_hint->UpperBound : 100;
00437 add_subwindow(new BC_Title(x,
00438 y + title_vmargin,
00439 string));
00440 add_subwindow(ilinear = new PluginACLientILinear(
00441 plugin,
00442 (current_port % 2) ? x2 : x3,
00443 y,
00444 &plugin->config.port_data[current_port],
00445 (int)min,
00446 (int)max));
00447 ipots.append(ilinear);
00448 break;
00449 }
00450 }
00451 current_port++;
00452 y += 30;
00453
00454 }
00455 }
00456
00457 y += 10;
00458 sprintf(string, _("Author: %s"), server->lad_descriptor->Maker);
00459 add_subwindow(new BC_Title(x, y, string));
00460 y += 20;
00461 sprintf(string, _("License: %s"), server->lad_descriptor->Copyright);
00462 add_subwindow(new BC_Title(x, y, string));
00463 }
00464
00465 int PluginAClientWindow::close_event()
00466 {
00467 set_done(1);
00468 return 1;
00469 }
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 PLUGIN_THREAD_OBJECT(PluginAClientLAD, PluginAClientThread, PluginAClientWindow)
00483
00484
00485
00486
00487
00488 PluginAClientLAD::PluginAClientLAD(PluginServer *server)
00489 : PluginAClient(server)
00490 {
00491 PLUGIN_CONSTRUCTOR_MACRO
00492 in_buffers = 0;
00493 total_inbuffers = 0;
00494 out_buffers = 0;
00495 total_outbuffers = 0;
00496 buffer_allocation = 0;
00497 lad_instance = 0;
00498 }
00499
00500 PluginAClientLAD::~PluginAClientLAD()
00501 {
00502 PLUGIN_DESTRUCTOR_MACRO
00503 delete_buffers();
00504 delete_plugin();
00505 }
00506
00507 int PluginAClientLAD::is_realtime()
00508 {
00509 return 1;
00510 }
00511
00512 int PluginAClientLAD::is_multichannel()
00513 {
00514 if(get_inchannels() > 1 || get_outchannels() > 1) return 1;
00515 return 0;
00516 }
00517
00518 int PluginAClientLAD::get_inchannels()
00519 {
00520 int result = 0;
00521 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00522 {
00523 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
00524 LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
00525 result++;
00526 }
00527 return result;
00528 }
00529
00530 int PluginAClientLAD::get_outchannels()
00531 {
00532 int result = 0;
00533 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00534 {
00535 if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
00536 LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
00537 result++;
00538 }
00539 return result;
00540 }
00541
00542
00543 char* PluginAClientLAD::plugin_title()
00544 {
00545 return (char*)server->lad_descriptor->Name;
00546 }
00547
00548 int PluginAClientLAD::uses_gui()
00549 {
00550 return 1;
00551 }
00552
00553 int PluginAClientLAD::is_synthesis()
00554 {
00555 return 1;
00556 }
00557
00558 VFrame* PluginAClientLAD::new_picon()
00559 {
00560 return new VFrame(lad_picon_png);
00561 }
00562
00563 SHOW_GUI_MACRO(PluginAClientLAD, PluginAClientThread)
00564 RAISE_WINDOW_MACRO(PluginAClientLAD)
00565 SET_STRING_MACRO(PluginAClientLAD)
00566 LOAD_CONFIGURATION_MACRO(PluginAClientLAD, PluginAClientConfig)
00567
00568 void PluginAClientLAD::update_gui()
00569 {
00570 }
00571
00572 char* PluginAClientLAD::lad_to_string(char *string, char *input)
00573 {
00574 strcpy(string, input);
00575 for(int j = 0; j < strlen(string); j++)
00576 {
00577 if(string[j] == ' ' ||
00578 string[j] == '<' ||
00579 string[j] == '>') string[j] = '_';
00580 }
00581 return string;
00582 }
00583
00584 char* PluginAClientLAD::lad_to_upper(char *string, char *input)
00585 {
00586 lad_to_string(string, input);
00587 for(int j = 0; j < strlen(string); j++)
00588 string[j] = toupper(string[j]);
00589 return string;
00590 }
00591
00592
00593 int PluginAClientLAD::load_defaults()
00594 {
00595 char directory[BCTEXTLEN];
00596 char string[BCTEXTLEN];
00597
00598
00599 strcpy(string, plugin_title());
00600 for(int i = 0; i < strlen(string); i++)
00601 if(string[i] == ' ') string[i] = '_';
00602
00603 sprintf(directory, "%s%s.rc", BCASTDIR, string);
00604
00605
00606
00607 defaults = new Defaults(directory);
00608 defaults->load();
00609 config.initialize(server);
00610
00611 int current_port = 0;
00612 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00613 {
00614 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00615 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00616 {
00617 PluginAClientLAD::lad_to_upper(string,
00618 (char*)server->lad_descriptor->PortNames[i]);
00619
00620 config.port_data[current_port] =
00621 defaults->get(string,
00622 config.port_data[current_port]);
00623
00624 current_port++;
00625 }
00626 }
00627 return 0;
00628 }
00629
00630
00631 int PluginAClientLAD::save_defaults()
00632 {
00633 char string[BCTEXTLEN];
00634 int current_port = 0;
00635 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00636 {
00637 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00638 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00639 {
00640
00641 PluginAClientLAD::lad_to_upper(string,
00642 (char*)server->lad_descriptor->PortNames[i]);
00643
00644 defaults->update(string, config.port_data[current_port]);
00645
00646 current_port++;
00647 }
00648 }
00649 defaults->save();
00650 return 0;
00651 }
00652
00653
00654
00655 void PluginAClientLAD::save_data(KeyFrame *keyframe)
00656 {
00657 FileXML output;
00658 char string[BCTEXTLEN];
00659
00660
00661 output.set_shared_string(keyframe->data, MESSAGESIZE);
00662 output.tag.set_title(lad_to_upper(string, plugin_title()));
00663
00664 int current_port = 0;
00665
00666 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00667 {
00668 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00669 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00670 {
00671
00672 PluginAClientLAD::lad_to_upper(string,
00673 (char*)server->lad_descriptor->PortNames[i]);
00674
00675 output.tag.set_property(string, config.port_data[current_port]);
00676
00677 current_port++;
00678 }
00679 }
00680
00681 output.append_tag();
00682 output.terminate_string();
00683 }
00684
00685 void PluginAClientLAD::read_data(KeyFrame *keyframe)
00686 {
00687 FileXML input;
00688 char string[BCTEXTLEN];
00689
00690 input.set_shared_string(keyframe->data, strlen(keyframe->data));
00691 config.initialize(server);
00692
00693 int result = 0;
00694 while(!result)
00695 {
00696 result = input.read_tag();
00697
00698 if(!result)
00699 {
00700
00701 if(input.tag.title_is(lad_to_upper(string, plugin_title())))
00702 {
00703 int current_port = 0;
00704 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00705 {
00706 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
00707 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
00708 {
00709 PluginAClientLAD::lad_to_upper(string,
00710 (char*)server->lad_descriptor->PortNames[i]);
00711
00712 config.port_data[current_port] =
00713 input.tag.get_property(string,
00714 config.port_data[current_port]);
00715
00716 current_port++;
00717 }
00718 }
00719 }
00720 }
00721 }
00722 }
00723
00724 void PluginAClientLAD::delete_buffers()
00725 {
00726 if(in_buffers)
00727 {
00728 for(int i = 0; i < total_inbuffers; i++) delete [] in_buffers[i];
00729 }
00730 if(out_buffers)
00731 {
00732 for(int i = 0; i < total_outbuffers; i++) delete [] out_buffers[i];
00733 }
00734 in_buffers = 0;
00735 out_buffers = 0;
00736 total_inbuffers = 0;
00737 total_outbuffers = 0;
00738 buffer_allocation = 0;
00739 }
00740
00741 void PluginAClientLAD::delete_plugin()
00742 {
00743 if(lad_instance)
00744 {
00745 if(server->lad_descriptor->deactivate)
00746 server->lad_descriptor->deactivate(lad_instance);
00747 server->lad_descriptor->cleanup(lad_instance);
00748 }
00749 lad_instance = 0;
00750 }
00751
00752 void PluginAClientLAD::init_plugin(int total_in, int total_out, int size)
00753 {
00754
00755 if(buffer_allocation && buffer_allocation < size)
00756 {
00757 delete_buffers();
00758 }
00759
00760 buffer_allocation = MAX(size, buffer_allocation);
00761 if(!in_buffers)
00762 {
00763 total_inbuffers = total_in;
00764 in_buffers = new LADSPA_Data*[total_inbuffers];
00765 for(int i = 0; i < total_inbuffers; i++)
00766 in_buffers[i] = new LADSPA_Data[buffer_allocation];
00767 }
00768
00769 if(!out_buffers)
00770 {
00771 total_outbuffers = total_out;
00772 out_buffers = new LADSPA_Data*[total_outbuffers];
00773 for(int i = 0; i < total_outbuffers; i++)
00774 out_buffers[i] = new LADSPA_Data[buffer_allocation];
00775 }
00776
00777 int need_reconfigure = 0;
00778 if(!lad_instance)
00779 {
00780 need_reconfigure = 1;
00781 }
00782 need_reconfigure |= load_configuration();
00783
00784 if(need_reconfigure)
00785 {
00786 delete_plugin();
00787 lad_instance = server->lad_descriptor->instantiate(
00788 server->lad_descriptor,
00789 PluginAClient::project_sample_rate);
00790
00791 int current_port = 0;
00792 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00793 {
00794 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
00795 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i]))
00796 {
00797 server->lad_descriptor->connect_port(lad_instance,
00798 i,
00799 config.port_data + current_port);
00800
00801 current_port++;
00802 }
00803 else
00804 if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
00805 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i]))
00806 {
00807 server->lad_descriptor->connect_port(lad_instance,
00808 i,
00809 &dummy_control_output);
00810 }
00811 }
00812 if(server->lad_descriptor->activate)
00813 server->lad_descriptor->activate(lad_instance);
00814 need_reconfigure = 0;
00815 }
00816
00817 int current_port = 0;
00818 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00819 {
00820 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
00821 LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
00822 {
00823 server->lad_descriptor->connect_port(lad_instance,
00824 i,
00825 in_buffers[current_port]);
00826 current_port++;
00827 }
00828 }
00829
00830 current_port = 0;
00831 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
00832 {
00833 if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
00834 LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
00835 {
00836 server->lad_descriptor->connect_port(lad_instance,
00837 i,
00838 out_buffers[current_port]);
00839 current_port++;
00840 }
00841 }
00842
00843 }
00844
00845 int PluginAClientLAD::process_realtime(int64_t size,
00846 double *input_ptr,
00847 double *output_ptr)
00848 {
00849 int in_channels = get_inchannels();
00850 int out_channels = get_outchannels();
00851 init_plugin(in_channels, out_channels, size);
00852
00853
00854 for(int i = 0; i < in_channels; i++)
00855 {
00856 LADSPA_Data *in_buffer = in_buffers[i];
00857 for(int j = 0; j < size; j++)
00858 in_buffer[j] = input_ptr[j];
00859 }
00860 for(int i = 0; i < out_channels; i++)
00861 bzero(out_buffers[i], sizeof(float) * size);
00862
00863
00864 server->lad_descriptor->run(lad_instance, size);
00865
00866
00867 LADSPA_Data *out_buffer = out_buffers[0];
00868 for(int i = 0; i < size; i++)
00869 {
00870 output_ptr[i] = out_buffer[i];
00871 }
00872
00873 return size;
00874 }
00875
00876 int PluginAClientLAD::process_realtime(int64_t size,
00877 double **input_ptr,
00878 double **output_ptr)
00879 {
00880 int in_channels = get_inchannels();
00881 int out_channels = get_outchannels();
00882
00883
00884 init_plugin(in_channels, out_channels, size);
00885
00886
00887 for(int i = 0; i < in_channels; i++)
00888 {
00889 float *in_buffer = in_buffers[i];
00890 double *in_ptr;
00891 if(i < PluginClient::total_in_buffers)
00892 in_ptr = input_ptr[i];
00893 else
00894 in_ptr = input_ptr[0];
00895 for(int j = 0; j < size; j++)
00896 in_buffer[j] = in_ptr[j];
00897 }
00898
00899 for(int i = 0; i < out_channels; i++)
00900 bzero(out_buffers[i], sizeof(float) * size);
00901
00902
00903 server->lad_descriptor->run(lad_instance, size);
00904
00905
00906 for(int i = 0; i < PluginClient::total_out_buffers; i++)
00907 {
00908 if(i < total_outbuffers)
00909 {
00910 LADSPA_Data *out_buffer = out_buffers[i];
00911 double *out_ptr = output_ptr[i];
00912 for(int j = 0; j < size; j++)
00913 out_ptr[j] = out_buffer[j];
00914 }
00915 }
00916
00917 return size;
00918 }
00919
00920
00921