4 #include "edlsession.h"
8 #include "mainprogress.h"
10 #include "mwindowgui.h"
11 #include "pluginarray.h"
12 #include "pluginserver.h"
13 #include "preferences.h"
14 #include "bcprogressbox.h"
19 PluginArray::PluginArray(int data_type)
20 : ArrayList<PluginServer*>()
22 this->data_type = data_type;
25 PluginArray::~PluginArray()
32 PluginServer* PluginArray::scan_plugindb(char *title)
34 return mwindow->scan_plugindb(title, data_type);
37 int PluginArray::start_plugins(MWindow *mwindow,
39 PluginServer *plugin_server,
45 this->mwindow = mwindow;
47 this->plugin_server = plugin_server;
48 this->keyframe = keyframe;
53 cache = new CICache(mwindow->preferences, mwindow->plugindb);
54 buffer_size = get_bufsize();
55 get_recordable_tracks();
59 if(!plugin_server->realtime)
64 if(!plugin_server->multichannel)
66 // ============================ single channel plugins
67 // start 1 plugin for each track
68 for(i = 0; i < total_tracks(); i++)
70 append(plugin = new PluginServer(*plugin_server));
71 plugin->set_mwindow(mwindow);
72 plugin->set_keyframe(keyframe);
73 plugin->append_module(modules[i]);
74 plugin->open_plugin(0,
79 if(i == 0) plugin->set_interactive();
80 plugin->start_loop(start, end, buffer_size, 1);
85 // ============================ multichannel
86 // start 1 plugin for all tracks
87 append(plugin = new PluginServer(*plugin_server));
88 plugin->set_mwindow(mwindow);
89 plugin->set_keyframe(keyframe);
90 for(i = 0; i < total_tracks(); i++)
91 plugin->append_module(modules[i]);
92 plugin->open_plugin(0,
97 // set one plugin for progress bars
98 plugin->set_interactive();
99 plugin->start_loop(start, end, buffer_size, total_tracks());
102 //printf("PluginArray::start_plugins 5\n");
106 PluginServer *plugin;
109 if(!plugin_server->multichannel)
111 // single channel plugins
112 // start 1 plugin for each track
113 for(i = 0; i < total_tracks(); i++)
115 append(plugin = new PluginServer(*plugin_server));
116 plugin->set_mwindow(mwindow);
117 plugin->set_keyframe(keyframe);
118 plugin->append_module(modules[i]);
119 plugin->open_plugin(0,
120 mwindow->preferences,
124 plugin->get_parameters(start, end, 1);
125 plugin->init_realtime(0, 1, get_bufsize());
131 // start 1 plugin for all tracks
132 append(plugin = new PluginServer(*plugin_server));
133 plugin->set_mwindow(mwindow);
134 plugin->set_keyframe(keyframe);
135 for(i = 0; i < total_tracks(); i++)
136 plugin->append_module(modules[i]);
137 plugin->open_plugin(0,
138 mwindow->preferences,
142 plugin->get_parameters(start, end, total_tracks());
143 plugin->init_realtime(0, total_tracks(), get_bufsize());
146 //printf("PluginArray::start_plugins 8\n");
154 int PluginArray::run_plugins()
157 // Length to write after process_loop
158 int64_t write_length;
160 done = 0; // for when done
162 if(plugin_server->realtime)
165 MainProgressBar *progress;
166 char string[BCTEXTLEN], string2[BCTEXTLEN];
168 sprintf(string, _("%s..."), plugin_server->title);
169 progress = mwindow->mainprogress->start_progress(string, end - start);
171 for(int current_position = start;
172 current_position < end && !done && !error;
173 current_position += len)
176 if(current_position + len > end) len = end - current_position;
178 // Process in plugin. This pulls data from the modules
180 for(i = 0; i < total; i++)
182 process_realtime(i, current_position, len);
186 error = write_buffers(len);
187 done = progress->update(current_position - start + len);
190 progress->get_time(string2);
191 progress->stop_progress();
194 sprintf(string, _("%s took %s"), plugin_server->title, string2);
195 mwindow->gui->lock_window();
196 mwindow->gui->show_message(string2);
197 mwindow->gui->unlock_window();
201 // Run main loop once for multichannel plugins.
202 // Run multiple times for single channel plugins.
203 // Each write to the file must contain all the channels
204 while(!done && !error)
206 for(i = 0; i < total; i++)
209 done += process_loop(i, write_length);
214 error = write_buffers(write_length);
222 int PluginArray::stop_plugins()
224 if(plugin_server->realtime)
226 for(int i = 0; i < total; i++)
228 values[i]->close_plugin();
233 for(int i = 0; i < total; i++)
235 values[i]->stop_loop();
236 values[i]->close_plugin();
247 // c-file-style: "linux"