r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / pluginaclientlad.C
blobb54e871bb957fd27f3af27fb37734af21fe70b3e
1 #include "clip.h"
2 #include "data/lad_picon_png.h"
3 #include "defaults.h"
4 #include "filexml.h"
5 #include "pluginaclientlad.h"
6 #include "pluginserver.h"
7 #include "vframe.h"
9 #include <ctype.h>
10 #include <string.h>
12 #include <libintl.h>
13 #define _(String) gettext(String)
14 #define gettext_noop(String) String
15 #define N_(String) gettext_noop (String)
19 PluginAClientConfig::PluginAClientConfig()
21         reset();
24 PluginAClientConfig::~PluginAClientConfig()
26         delete_objects();
29 void PluginAClientConfig::reset()
31         total_ports = 0;
32         port_data = 0;
33         port_type = 0;
36 void PluginAClientConfig::delete_objects()
38         if(port_data)
39                 delete [] port_data;
40         if(port_type)
41                 delete [] port_type;
42         reset();
46 int PluginAClientConfig::equivalent(PluginAClientConfig &that)
48         if(that.total_ports != total_ports) return 0;
49         for(int i = 0; i < total_ports; i++)
50                 if(!EQUIV(port_data[i], that.port_data[i])) return 0;
51         return 1;
54 // Need PluginServer to do this.
55 void PluginAClientConfig::copy_from(PluginAClientConfig &that)
57         if(total_ports != that.total_ports)
58         {
59                 delete_objects();
60                 total_ports = that.total_ports;
61                 port_data = new LADSPA_Data[total_ports];
62                 port_type = new int[total_ports];
63         }
65         for(int i = 0; i < total_ports; i++)
66         {
67                 port_type[i] = that.port_type[i];
68                 port_data[i] = that.port_data[i];
69 //printf("PluginAClientConfig::copy_from 1 %f %f\n", port_data[i], that.port_data[i]);
70         }
74 void PluginAClientConfig::interpolate(PluginAClientConfig &prev, 
75         PluginAClientConfig &next, 
76         int64_t prev_frame, 
77         int64_t next_frame, 
78         int64_t current_frame)
80         copy_from(prev);
83 void PluginAClientConfig::initialize(PluginServer *server)
85         delete_objects();
87         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
88         {
89                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
90                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
91                 {
92                         total_ports++;
93                 }
94         }
96         port_data = new LADSPA_Data[total_ports];
97         port_type = new int[total_ports];
99         int current_port = 0;
100         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
101         {
102                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
103                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
104                 {
105 // Convert LAD default to default value
106                         float value = 0.0;
107                         const LADSPA_PortRangeHint *lad_hint = &server->lad_descriptor->PortRangeHints[i];
108                         LADSPA_PortRangeHintDescriptor hint_desc = lad_hint->HintDescriptor;
110 // Store type of port for GUI use
111                         port_type[current_port] = PORT_NORMAL;
112                         if(LADSPA_IS_HINT_SAMPLE_RATE(hint_desc))/* &&
113                                 !LADSPA_IS_HINT_BOUNDED_ABOVE(hint_desc) &&
114                                 !LADSPA_IS_HINT_BOUNDED_BELOW(hint_desc))*/
115                         {
116 // LAD frequency table
117                                 port_type[current_port] = PORT_FREQ_INDEX;
118                         }
119                         else
120                         if(LADSPA_IS_HINT_TOGGLED(hint_desc))
121                                 port_type[current_port] = PORT_TOGGLE;
122                         else
123                         if(LADSPA_IS_HINT_INTEGER(hint_desc))
124                                 port_type[current_port] = PORT_INTEGER;
131 // Get default of port using crazy hinting system
132                         if(LADSPA_IS_HINT_DEFAULT_0(hint_desc))
133                                 value = 0.0;
134                         else
135                         if(LADSPA_IS_HINT_DEFAULT_1(hint_desc))
136                                 value = 1.0;
137                         else
138                         if(LADSPA_IS_HINT_DEFAULT_100(hint_desc))
139                                 value = 100.0;
140                         else
141                         if(LADSPA_IS_HINT_DEFAULT_440(hint_desc))
142                         {
143                                 if(port_type[current_port] == PORT_FREQ_INDEX)
144                                         value = 440.0 / 44100;
145                                 else
146                                         value = 440.0;
147                         }
148                         else
149                         if(LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_desc))
150                                 value = lad_hint->UpperBound;
151                         else
152                         if(LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_desc))
153                                 value = lad_hint->LowerBound;
154                         else
155                         if(LADSPA_IS_HINT_DEFAULT_LOW(hint_desc))
156                         {
157                                 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
158                                         value = exp(log(lad_hint->LowerBound) * 0.25 +
159                                                 log(lad_hint->UpperBound) * 0.75);
160                                 else
161                                         value = lad_hint->LowerBound * 0.25 +
162                                                 lad_hint->UpperBound * 0.75;
163                         }
164                         else
165                         if(LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_desc))
166                         {
167                                 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
168                                         value = exp(log(lad_hint->LowerBound) * 0.5 +
169                                                 log(lad_hint->UpperBound) * 0.5);
170                                 else
171                                         value = lad_hint->LowerBound * 0.5 +
172                                                 lad_hint->UpperBound * 0.5;
173                         }
174                         else
175                         if(LADSPA_IS_HINT_DEFAULT_HIGH(hint_desc))
176                         {
177                                 if(LADSPA_IS_HINT_LOGARITHMIC(hint_desc))
178                                         value = exp(log(lad_hint->LowerBound) * 0.75 +
179                                                 log(lad_hint->UpperBound) * 0.25);
180                                 else
181                                         value = lad_hint->LowerBound * 0.75 +
182                                                 lad_hint->UpperBound * 0.25;
183                         }
193                         port_data[current_port] = value;
194                         current_port++;
195                 }
196         }
209 PluginACLientToggle::PluginACLientToggle(PluginAClientLAD *plugin,
210         int x,
211         int y,
212         LADSPA_Data *output)
213  : BC_CheckBox(x, y, (int)(*output))
215         this->plugin = plugin;
216         this->output = output;
219 int PluginACLientToggle::handle_event()
221         *output = get_value();
222         plugin->send_configure_change();
223         return 1;
232 PluginACLientILinear::PluginACLientILinear(PluginAClientLAD *plugin,
233         int x,
234         int y,
235         LADSPA_Data *output,
236         int min,
237         int max)
238  : BC_IPot(x, y, (int)(*output), min, max)
240         this->plugin = plugin;
241         this->output = output;
244 int PluginACLientILinear::handle_event()
246         *output = get_value();
247         plugin->send_configure_change();
248         return 1;
256 PluginACLientFLinear::PluginACLientFLinear(PluginAClientLAD *plugin,
257         int x,
258         int y,
259         LADSPA_Data *output,
260         float min,
261         float max)
262  : BC_FPot(x, y, *output, min, max)
264         this->plugin = plugin;
265         this->output = output;
266         set_precision(0.01);
269 int PluginACLientFLinear::handle_event()
271         *output = get_value();
272         plugin->send_configure_change();
273         return 1;
282 PluginACLientFreq::PluginACLientFreq(PluginAClientLAD *plugin,
283         int x,
284         int y,
285         LADSPA_Data *output,
286         int translate_linear)
287  : BC_QPot(x, 
288         y, 
289         translate_linear ?
290                 (int)(*output * plugin->PluginAClient::project_sample_rate) :
291                 (int)*output)
293 //printf("PluginACLientFreq::PluginACLientFreq 1 %f\n", *output);
294         this->plugin = plugin;
295         this->output = output;
296         this->translate_linear = translate_linear;
299 int PluginACLientFreq::handle_event()
301         *output = translate_linear ?
302                 (float)get_value() / plugin->PluginAClient::project_sample_rate :
303                 get_value();
304 //printf("PluginACLientFreq::handle_event 1 %f %d %d\n", *output, get_value(), plugin->PluginAClient::project_sample_rate);
305         plugin->send_configure_change();
306         return 1;
317 PluginAClientWindow::PluginAClientWindow(PluginAClientLAD *plugin, 
318         int x, 
319         int y)
320  : BC_Window(plugin->gui_string, 
321         x,
322         y,
323         500, 
324         plugin->config.total_ports * 30 + 60, 
325         500, 
326         plugin->config.total_ports * 30 + 60, 
327         0, 
328         1)
330         this->plugin = plugin;
333 PluginAClientWindow::~PluginAClientWindow()
338 int PluginAClientWindow::create_objects()
340         PluginServer *server = plugin->server;
341         char string[BCTEXTLEN];
342         int current_port = 0;
343         int x = 10;
344         int y = 10;
345         int x2 = 300;
346         int x3 = 335;
347         int title_vmargin = 5;
348         int max_w = 0;
349         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
350         {
351                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
352                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
353                 {
354                         int w = get_text_width(MEDIUMFONT, (char*)server->lad_descriptor->PortNames[i]);
355                         if(w > max_w) max_w = w;
356                 }
357         }
359         x2 = max_w + 20;
360         x3 = max_w + 55;
361         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
362         {
363                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
364                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
365                 {
366                         const LADSPA_PortRangeHint *lad_hint = &server->lad_descriptor->PortRangeHints[i];
367                         LADSPA_PortRangeHintDescriptor hint_desc = lad_hint->HintDescriptor;
368                         int use_min = LADSPA_IS_HINT_BOUNDED_BELOW(hint_desc);
369                         int use_max = LADSPA_IS_HINT_BOUNDED_ABOVE(hint_desc);
370                         sprintf(string, "%s:", server->lad_descriptor->PortNames[i]);
372 // printf("PluginAClientWindow::create_objects 1 %s type=%d lower: %d %f upper: %d %f\n", 
373 // string,
374 // plugin->config.port_type[current_port],
375 // use_min,
376 // lad_hint->LowerBound, 
377 // use_max,
378 // lad_hint->UpperBound);
380                         switch(plugin->config.port_type[current_port])
381                         {
382                                 case PluginAClientConfig::PORT_NORMAL:
383                                 {
384                                         PluginACLientFLinear *flinear;
385                                         float min = use_min ? lad_hint->LowerBound : 0;
386                                         float max = use_max ? lad_hint->UpperBound : 100;
387                                         add_subwindow(new BC_Title(x, 
388                                                 y + title_vmargin, 
389                                                 string));
390                                         add_subwindow(flinear = new PluginACLientFLinear(
391                                                 plugin,
392                                                 (current_port % 2) ? x2 : x3,
393                                                 y,
394                                                 &plugin->config.port_data[current_port],
395                                                 min,
396                                                 max));
397                                         fpots.append(flinear);
398                                         break;
399                                 }
400                                 case PluginAClientConfig::PORT_FREQ_INDEX:
401                                 {
402                                         PluginACLientFreq *freq;
403                                         add_subwindow(new BC_Title(x, 
404                                                 y + title_vmargin, 
405                                                 string));
406                                         add_subwindow(freq = new PluginACLientFreq(
407                                                 plugin,
408                                                 (current_port % 2) ? x2 : x3,
409                                                 y,
410                                                 &plugin->config.port_data[current_port],
412 /*                                              (plugin->config.port_type[current_port] == 
413                                                         PluginAClientConfig::PORT_FREQ_INDEX
414 */));
415                                         freqs.append(freq);
416                                         break;
417                                 }
418                                 case PluginAClientConfig::PORT_TOGGLE:
419                                 {
420                                         PluginACLientToggle *toggle;
421                                         add_subwindow(new BC_Title(x, 
422                                                 y + title_vmargin, 
423                                                 string));
424                                         add_subwindow(toggle = new PluginACLientToggle(
425                                                 plugin,
426                                                 (current_port % 2) ? x2 : x3,
427                                                 y,
428                                                 &plugin->config.port_data[current_port]));
429                                         toggles.append(toggle);
430                                         break;
431                                 }
432                                 case PluginAClientConfig::PORT_INTEGER:
433                                 {
434                                         PluginACLientILinear *ilinear;
435                                         float min = use_min ? lad_hint->LowerBound : 0;
436                                         float max = use_max ? lad_hint->UpperBound : 100;
437                                         add_subwindow(new BC_Title(x, 
438                                                 y + title_vmargin, 
439                                                 string));
440                                         add_subwindow(ilinear = new PluginACLientILinear(
441                                                 plugin,
442                                                 (current_port % 2) ? x2 : x3,
443                                                 y,
444                                                 &plugin->config.port_data[current_port],
445                                                 (int)min,
446                                                 (int)max));
447                                         ipots.append(ilinear);
448                                         break;
449                                 }
450                         }
451                         current_port++;
452                         y += 30;
453 //printf("PluginAClientWindow::create_objects 2\n");
454                 }
455         }
457         y += 10;
458         sprintf(string, _("Author: %s"), server->lad_descriptor->Maker);
459         add_subwindow(new BC_Title(x, y, string));
460         y += 20;
461         sprintf(string, _("License: %s"), server->lad_descriptor->Copyright);
462         add_subwindow(new BC_Title(x, y, string));
465 int PluginAClientWindow::close_event()
467         set_done(1);
468         return 1;
482 PLUGIN_THREAD_OBJECT(PluginAClientLAD, PluginAClientThread, PluginAClientWindow)
488 PluginAClientLAD::PluginAClientLAD(PluginServer *server)
489  : PluginAClient(server)
491         PLUGIN_CONSTRUCTOR_MACRO
492         in_buffers = 0;
493         total_inbuffers = 0;
494         out_buffers = 0;
495         total_outbuffers = 0;
496         buffer_allocation = 0;
497         lad_instance = 0;
500 PluginAClientLAD::~PluginAClientLAD()
502         PLUGIN_DESTRUCTOR_MACRO
503         delete_buffers();
504         delete_plugin();
507 int PluginAClientLAD::is_realtime()
509         return 1;
512 int PluginAClientLAD::is_multichannel()
514         if(get_inchannels() > 1 || get_outchannels() > 1) return 1;
515         return 0;
518 int PluginAClientLAD::get_inchannels()
520         int result = 0;
521         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
522         {
523                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
524                         LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
525                         result++;
526         }
527         return result;
530 int PluginAClientLAD::get_outchannels()
532         int result = 0;
533         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
534         {
535                 if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
536                         LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
537                         result++;
538         }
539         return result;
543 char* PluginAClientLAD::plugin_title()
545         return (char*)server->lad_descriptor->Name;
548 int PluginAClientLAD::uses_gui()
550         return 1;
553 int PluginAClientLAD::is_synthesis()
555         return 1;
558 VFrame* PluginAClientLAD::new_picon()
560         return new VFrame(lad_picon_png);
563 SHOW_GUI_MACRO(PluginAClientLAD, PluginAClientThread)
564 RAISE_WINDOW_MACRO(PluginAClientLAD)
565 SET_STRING_MACRO(PluginAClientLAD)
566 LOAD_CONFIGURATION_MACRO(PluginAClientLAD, PluginAClientConfig)
568 void PluginAClientLAD::update_gui()
572 char* PluginAClientLAD::lad_to_string(char *string, char *input)
574         strcpy(string, input);
575         for(int j = 0; j < strlen(string); j++)
576         {
577                 if(string[j] == ' ' ||
578                         string[j] == '<' ||
579                         string[j] == '>') string[j] = '_';
580         }
581         return string;
584 char* PluginAClientLAD::lad_to_upper(char *string, char *input)
586         lad_to_string(string, input);
587         for(int j = 0; j < strlen(string); j++)
588                 string[j] = toupper(string[j]);
589         return string;
593 int PluginAClientLAD::load_defaults()
595         char directory[BCTEXTLEN];
596         char string[BCTEXTLEN];
599         strcpy(string, plugin_title());
600         for(int i = 0; i < strlen(string); i++)
601                 if(string[i] == ' ') string[i] = '_';
602 // set the default directory
603         sprintf(directory, "%s%s.rc", BCASTDIR, string);
604 //printf("PluginAClientLAD::load_defaults %s\n", directory);
606 // load the defaults
607         defaults = new Defaults(directory);
608         defaults->load();
609         config.initialize(server);
611         int current_port = 0;
612         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
613         {
614                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
615                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
616                 {
617                         PluginAClientLAD::lad_to_upper(string, 
618                                 (char*)server->lad_descriptor->PortNames[i]);
620                         config.port_data[current_port] = 
621                                 defaults->get(string, 
622                                         config.port_data[current_port]);
623 //printf("PluginAClientLAD::load_defaults %d %f\n", current_port, config.port_data[current_port]);
624                         current_port++;
625                 }
626         }
627         return 0;
631 int PluginAClientLAD::save_defaults()
633         char string[BCTEXTLEN];
634         int current_port = 0;
635         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
636         {
637                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
638                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
639                 {
640 // Convert LAD port name to default title
641                         PluginAClientLAD::lad_to_upper(string, 
642                                 (char*)server->lad_descriptor->PortNames[i]);
644                         defaults->update(string, config.port_data[current_port]);
645 //printf("PluginAClientLAD::save_defaults %d %f\n", current_port, config.port_data[current_port]);
646                         current_port++;
647                 }
648         }
649         defaults->save();
650         return 0;
655 void PluginAClientLAD::save_data(KeyFrame *keyframe)
657         FileXML output;
658         char string[BCTEXTLEN];
660 // cause data to be stored directly in text
661         output.set_shared_string(keyframe->data, MESSAGESIZE);
662         output.tag.set_title(lad_to_upper(string, plugin_title()));
664         int current_port = 0;
665 //printf("PluginAClientLAD::save_data %d\n", server->lad_descriptor->PortCount);
666         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
667         {
668                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
669                         LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
670                 {
671 // Convert LAD port name to default title
672                         PluginAClientLAD::lad_to_upper(string, 
673                                 (char*)server->lad_descriptor->PortNames[i]);
675                         output.tag.set_property(string, config.port_data[current_port]);
676 //printf("PluginAClientLAD::save_data %d %f\n", current_port, config.port_data[current_port]);
677                         current_port++;
678                 }
679         }
681         output.append_tag();
682         output.terminate_string();
685 void PluginAClientLAD::read_data(KeyFrame *keyframe)
687         FileXML input;
688         char string[BCTEXTLEN];
690         input.set_shared_string(keyframe->data, strlen(keyframe->data));
691         config.initialize(server);
693         int result = 0;
694         while(!result)
695         {
696                 result = input.read_tag();
698                 if(!result)
699                 {
700 //printf("PluginAClientLAD::read_data %s\n", input.tag.get_title());
701                         if(input.tag.title_is(lad_to_upper(string, plugin_title())))
702                         {
703                                 int current_port = 0;
704                                 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
705                                 {
706                                         if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i] &&
707                                                 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i])))
708                                         {
709                                                 PluginAClientLAD::lad_to_upper(string, 
710                                                         (char*)server->lad_descriptor->PortNames[i]);
712                                                 config.port_data[current_port] = 
713                                                         input.tag.get_property(string, 
714                                                                 config.port_data[current_port]);
715 //printf("PluginAClientLAD::read_data %d %f\n", current_port, config.port_data[current_port]);
716                                                 current_port++;
717                                         }
718                                 }
719                         }
720                 }
721         }
724 void PluginAClientLAD::delete_buffers()
726         if(in_buffers)
727         {
728                 for(int i = 0; i < total_inbuffers; i++) delete [] in_buffers[i];
729         }
730         if(out_buffers)
731         {
732                 for(int i = 0; i < total_outbuffers; i++) delete [] out_buffers[i];
733         }
734         in_buffers = 0;
735         out_buffers = 0;
736         total_inbuffers = 0;
737         total_outbuffers = 0;
738         buffer_allocation = 0;
741 void PluginAClientLAD::delete_plugin()
743         if(lad_instance)
744         {
745                 if(server->lad_descriptor->deactivate)
746                         server->lad_descriptor->deactivate(lad_instance);
747                 server->lad_descriptor->cleanup(lad_instance);
748         }
749         lad_instance = 0;
752 void PluginAClientLAD::init_plugin(int total_in, int total_out, int size)
754 //printf("PluginAClientLAD::init_plugin 1\n");
755         if(buffer_allocation && buffer_allocation < size)
756         {
757                 delete_buffers();
758         }
760         buffer_allocation = MAX(size, buffer_allocation);
761         if(!in_buffers)
762         {
763                 total_inbuffers = total_in;
764                 in_buffers = new LADSPA_Data*[total_inbuffers];
765                 for(int i = 0; i < total_inbuffers; i++) 
766                         in_buffers[i] = new LADSPA_Data[buffer_allocation];
767         }
769         if(!out_buffers)
770         {
771                 total_outbuffers = total_out;
772                 out_buffers = new LADSPA_Data*[total_outbuffers];
773                 for(int i = 0; i < total_outbuffers; i++) 
774                         out_buffers[i] = new LADSPA_Data[buffer_allocation];
775         }
777         int need_reconfigure = 0;
778         if(!lad_instance)
779         {
780                 need_reconfigure = 1;
781         }
782         need_reconfigure |= load_configuration();
784         if(need_reconfigure)
785         {
786                 delete_plugin();
787                 lad_instance = server->lad_descriptor->instantiate(
788                         server->lad_descriptor,
789                         PluginAClient::project_sample_rate);
791                 int current_port = 0;
792                 for(int i = 0; i < server->lad_descriptor->PortCount; i++)
793                 {
794                         if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
795                                 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i]))
796                         {
797                                 server->lad_descriptor->connect_port(lad_instance,
798                                         i,
799                                         config.port_data + current_port);
800 //printf("PluginAClientLAD::init_plugin %d %f\n", current_port, config.port_data[current_port]);
801                                 current_port++;
802                         }
803                         else
804                         if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
805                                 LADSPA_IS_PORT_CONTROL(server->lad_descriptor->PortDescriptors[i]))
806                         {
807                                 server->lad_descriptor->connect_port(lad_instance,
808                                         i,
809                                         &dummy_control_output);
810                         }
811                 }
812                 if(server->lad_descriptor->activate)
813                         server->lad_descriptor->activate(lad_instance);
814                 need_reconfigure = 0;
815         }
817         int current_port = 0;
818         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
819         {
820                 if(LADSPA_IS_PORT_INPUT(server->lad_descriptor->PortDescriptors[i]) &&
821                         LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
822                 {
823                         server->lad_descriptor->connect_port(lad_instance,
824                                                 i,
825                                                 in_buffers[current_port]);
826                         current_port++;
827                 }
828         }
830         current_port = 0;
831         for(int i = 0; i < server->lad_descriptor->PortCount; i++)
832         {
833                 if(LADSPA_IS_PORT_OUTPUT(server->lad_descriptor->PortDescriptors[i]) &&
834                         LADSPA_IS_PORT_AUDIO(server->lad_descriptor->PortDescriptors[i]))
835                 {
836                         server->lad_descriptor->connect_port(lad_instance,
837                                                 i,
838                                                 out_buffers[current_port]);
839                         current_port++;
840                 }
841         }
842 //printf("PluginAClientLAD::init_plugin 10\n");
845 int PluginAClientLAD::process_realtime(int64_t size, 
846         double *input_ptr, 
847         double *output_ptr)
849         int in_channels = get_inchannels();
850         int out_channels = get_outchannels();
851         init_plugin(in_channels, out_channels, size);
853 //printf("PluginAClientLAD::process_realtime 1 %p\n", lad_instance);
854         for(int i = 0; i < in_channels; i++)
855         {
856                 LADSPA_Data *in_buffer = in_buffers[i];
857                 for(int j = 0; j < size; j++)
858                         in_buffer[j] = input_ptr[j];
859         }
860         for(int i = 0; i < out_channels; i++)
861                 bzero(out_buffers[i], sizeof(float) * size);
862 //printf("PluginAClientLAD::process_realtime 4\n");
864         server->lad_descriptor->run(lad_instance, size);
865 //printf("PluginAClientLAD::process_realtime 5\n");
867         LADSPA_Data *out_buffer = out_buffers[0];
868         for(int i = 0; i < size; i++)
869         {
870                 output_ptr[i] = out_buffer[i];
871         }
872 //printf("PluginAClientLAD::process_realtime 6\n");
873         return size;
876 int PluginAClientLAD::process_realtime(int64_t size, 
877         double **input_ptr, 
878         double **output_ptr)
880         int in_channels = get_inchannels();
881         int out_channels = get_outchannels();
882 // printf("PluginAClientLAD::process_realtime 2 %p %d %d %d %d\n", 
883 // lad_instance, in_channels, out_channels, PluginClient::total_in_buffers, PluginClient::total_out_buffers);
884         init_plugin(in_channels, out_channels, size);
885 //printf("PluginAClientLAD::process_realtime 2 %p\n", lad_instance);
887         for(int i = 0; i < in_channels; i++)
888         {
889                 float *in_buffer = in_buffers[i];
890                 double *in_ptr;
891                 if(i < PluginClient::total_in_buffers)
892                         in_ptr = input_ptr[i];
893                 else
894                         in_ptr = input_ptr[0];
895                 for(int j = 0; j < size; j++)
896                         in_buffer[j] = in_ptr[j];
897         }
898 //printf("PluginAClientLAD::process_realtime 2 %p\n", lad_instance);
899         for(int i = 0; i < out_channels; i++)
900                 bzero(out_buffers[i], sizeof(float) * size);
901 //printf("PluginAClientLAD::process_realtime 2 %p\n", lad_instance);
903         server->lad_descriptor->run(lad_instance, size);
904 //printf("PluginAClientLAD::process_realtime 2 %p\n", lad_instance);
906         for(int i = 0; i < PluginClient::total_out_buffers; i++)
907         {
908                 if(i < total_outbuffers)
909                 {
910                         LADSPA_Data *out_buffer = out_buffers[i];
911                         double *out_ptr = output_ptr[i];
912                         for(int j = 0; j < size; j++)
913                                 out_ptr[j] = out_buffer[j];
914                 }
915         }
916 //printf("PluginAClientLAD::process_realtime 3 %p\n", lad_instance);
917         return size;