1 /*
2  * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3  * Copyright (C) 2011 Pete Shorthose
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 Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  * --------------------------------------------------------------------------
19  *
20  *
21  *    This is the guitarix engine definitions
22  *
23  *
24  * --------------------------------------------------------------------------
25  */
26 
27 #include "engine.h"
28 #include "valve.h"
29 
30 #include "gx_faust_plugins.h"
31 #include "../plugins/pluginlib.h"
32 
33 namespace gx_engine {
34 
35 /****************************************************************
36  ** class GxEngine
37  */
38 
39 static plugindef_creator builtin_crybaby_plugins[] = {
40     gx_effects::crybaby::plugin,
41     gx_effects::autowah::plugin,
42     0
43 };
44 
load_crybaby_ui(const UiBuilder & builder,int format)45 static int load_crybaby_ui(const UiBuilder& builder, int format) {
46     if (format & UI_FORM_GLADE) {
47 	builder.load_glade_file("crybaby_ui.glade");
48 	return 0;
49     }
50     if (format & UI_FORM_STACK) {
51 	builder.openHorizontalhideBox("");
52 	builder.create_master_slider("crybaby.level", _("  level  "));
53 	builder.closeBox();
54 	builder.openHorizontalBox("");
55 	{
56 	    builder.insertSpacer();
57 	    builder.create_selector("crybaby.autowah", _("Mode"));
58 	    builder.insertSpacer();
59 	    builder.insertSpacer();
60 	    builder.openHorizontalTableBox("");
61 	    {
62 		builder.create_small_rackknobr("crybaby.wah", _("  wah   "));
63 		builder.create_small_rackknob("crybaby.level", _("  level  "));
64 		builder.create_small_rackknob("crybaby.wet_dry", _("  dry/wet  "));
65 	    }
66 	    builder.closeBox();
67 	    builder.insertSpacer();
68 	}
69 	builder.closeBox();
70 	return 0;
71     }
72     return -1;
73 }
74 
75 static plugindef_creator builtin_wah_plugins[] = {
76     gx_effects::colwah::plugin,
77     gx_effects::dallaswah::plugin,
78     gx_effects::foxwah::plugin,
79     gx_effects::jenwah::plugin,
80     gx_effects::maestrowah::plugin,
81     gx_effects::selwah::plugin,
82     gx_effects::voxwah::plugin,
83     gx_effects::rolwah::plugin,
84     gx_effects::colbwah::plugin,
85     gx_effects::jenbasswah::plugin,
86    0
87 };
88 
load_wah_ui(const UiBuilder & builder,int format)89 static int load_wah_ui(const UiBuilder& builder, int format) {
90     if (format & UI_FORM_GLADE) {
91 	builder.load_glade_file("wah_ui.glade");
92 	return 0;
93     }
94     if (format & UI_FORM_STACK) {
95 	builder.openHorizontalhideBox("");
96 	builder.create_master_slider("wah.Wah", _("Wah"));
97 	builder.closeBox();
98 	builder.openHorizontalBox("");
99 	{
100 		builder.openVerticalBox("");
101 		{
102 	    builder.insertSpacer();
103 	    builder.create_selector("wah.select", _("Model"));
104 	    builder.insertSpacer();
105 		builder.create_selector("wah.mode", _("Mode"));
106 	    builder.insertSpacer();
107 	    }
108 	    builder.closeBox();
109 	    builder.openHorizontalTableBox("");
110 	    {
111 		builder.create_small_rackknobr("wah.Wah", _("Wah"));
112 		builder.create_small_rackknob("wah.freq", _("Alien Freq"));
113 		builder.create_small_rackknob("wah.wet_dry", _("  dry/wet  "));
114 	    }
115 	    builder.closeBox();
116 	    builder.insertSpacer();
117 	}
118 	builder.closeBox();
119 	return 0;
120     }
121     return -1;
122 }
123 
124 static plugindef_creator builtin_tonestack_plugins[] = {
125     gx_tonestacks::tonestack_default::plugin,
126     gx_tonestacks::tonestack_bassman::plugin,
127     gx_tonestacks::tonestack_twin::plugin,
128     gx_tonestacks::tonestack_princeton::plugin,
129     gx_tonestacks::tonestack_jcm800::plugin,
130     gx_tonestacks::tonestack_jcm2000::plugin,
131     gx_tonestacks::tonestack_mlead::plugin,
132     gx_tonestacks::tonestack_m2199::plugin,
133     gx_tonestacks::tonestack_ac30::plugin,
134     gx_tonestacks::tonestack_soldano::plugin,
135     gx_tonestacks::tonestack_mesa::plugin,
136     gx_tonestacks::tonestack_jtm45::plugin,
137     gx_tonestacks::tonestack_ac15::plugin,
138     gx_tonestacks::tonestack_peavey::plugin,
139     gx_tonestacks::tonestack_ibanez::plugin,
140     gx_tonestacks::tonestack_roland::plugin,
141     gx_tonestacks::tonestack_ampeg::plugin,
142     gx_tonestacks::tonestack_ampeg_rev::plugin,
143     gx_tonestacks::tonestack_sovtek::plugin,
144     gx_tonestacks::tonestack_bogner::plugin,
145     gx_tonestacks::tonestack_groove::plugin,
146     gx_tonestacks::tonestack_crunch::plugin,
147     gx_tonestacks::tonestack_fender_blues::plugin,
148     gx_tonestacks::tonestack_fender_default::plugin,
149     gx_tonestacks::tonestack_fender_deville::plugin,
150     gx_tonestacks::tonestack_gibsen::plugin,
151     gx_tonestacks::tonestack_engl::plugin,
152     0
153 };
154 
load_tonestack_ui(const UiBuilder & builder,int format)155 static int load_tonestack_ui(const UiBuilder& builder, int format) {
156     if (format & UI_FORM_GLADE) {
157 	builder.load_glade_file("amp.tonestack_ui.glade");
158 	return 0;
159     }
160     if (format & UI_FORM_STACK) {
161 	builder.openHorizontalhideBox("");
162 	builder.create_selector("amp.tonestack.select", 0);
163 	builder.closeBox();
164 	builder.openVerticalBox("");
165 	{
166 	    builder.openHorizontalBox("");
167 	    {
168 		builder.create_selector("amp.tonestack.select", 0);
169 		builder.create_small_rackknobr("amp.tonestack.Bass", _("bass"));
170 		builder.create_small_rackknobr("amp.tonestack.Middle", _("middle"));
171 		builder.create_small_rackknobr("amp.tonestack.Treble", _("treble"));
172 	    }
173 	    builder.closeBox();
174 	}
175 	builder.closeBox();
176 	return 0;
177     }
178     return -1;
179 }
180 
181 
182 static plugindef_creator builtin_amp_plugins[] = {
183     gx_amps::gxamp::plugin,
184     gx_amps::gxamp3::plugin,
185     gx_amps::gxamp14::plugin,
186     gx_amps::gxamp10::plugin,
187     gx_amps::gxamp18::plugin,
188 
189     gx_amps::gxamp2::plugin,
190 
191     gx_amps::gxamp9::plugin,
192     gx_amps::gxamp11::plugin,
193     gx_amps::gxamp17::plugin,
194     gx_amps::gxamp13::plugin,
195 
196     gx_amps::gxamp5::plugin,
197     gx_amps::gxamp4::plugin,
198     gx_amps::gxamp15::plugin,
199     gx_amps::gxamp12::plugin,
200 
201     gx_amps::gxamp7::plugin,
202     gx_amps::gxamp8::plugin,
203     gx_amps::gxamp16::plugin,
204     gx_amps::gxamp6::plugin,
205 
206     gx_amps::gxnoamp::plugin, // keep last position (UI switches controls)
207 
208     0
209 };
210 
211 static const char* ampstack_groups[] = {
212     ".amp2.stage1",  N_("Tube1"),
213     ".amp2.stage2",  N_("Tube2"),
214     ".tube",         N_("Tube 1"),
215     ".gxdistortion", N_("Multi Band Distortion"),
216     0
217 };
218 
219 static const char* poweramp_groups[] = {
220     ".poweramp.Pregain",  N_("Gain"),
221     ".poweramp.Gain",  N_("Out"),
222     0
223 };
224 
225 static plugindef_creator builtin_poweramp_plugins[] = {
226     gx_poweramps::champ::plugin,
227     gx_poweramps::epiphone::plugin,
228     gx_poweramps::princeton::plugin,
229     gx_poweramps::orangedarkterror::plugin,
230     gx_poweramps::plexiel34::plugin,
231     gx_poweramps::supersonic::plugin,
232     0
233 };
234 
load_poweramp_ui(const UiBuilder & builder,int format)235 static int load_poweramp_ui(const UiBuilder& builder, int format) {
236     if (format & UI_FORM_GLADE) {
237 	builder.load_glade_file("poweramps_ui.glade");
238 	return 0;
239     }
240     if (format & UI_FORM_STACK) {
241 	builder.openHorizontalhideBox("");
242 	builder.create_selector("poweramp.mode", _("Model"));
243 	builder.closeBox();
244 	builder.openHorizontalBox("");
245 	{
246 		builder.openVerticalBox("");
247 		{
248 	    builder.insertSpacer();
249 	    builder.create_selector("poweramp.mode", _("Model"));
250 	    builder.insertSpacer();
251 	    }
252 	    builder.closeBox();
253 	}
254 	builder.closeBox();
255 	return 0;
256     }
257     return -1;
258 };
259 
GxEngine(const string & plugin_dir,ParameterGroups & groups,const gx_system::CmdlineOptions & options)260 GxEngine::GxEngine(const string& plugin_dir, ParameterGroups& groups, const gx_system::CmdlineOptions& options)
261     : ModuleSequencer(),
262       resamp(),
263       plugin_changed(),
264       ladspaloader(options, get_param()),
265       controller_map(),
266       // ModuleSelector's
267       crybaby(
268 	  *this, "crybaby", N_("Crybaby"), N_("Guitar Effects"), builtin_crybaby_plugins,
269 	  "crybaby.autowah", _("select"), load_crybaby_ui, 0, PGN_POST_PRE),
270       wah(
271 	  *this, "wah", N_("Wah"), N_("Guitar Effects"), builtin_wah_plugins,
272 	  "wah.select", _("select"), load_wah_ui, 0, PGN_POST_PRE),
273       tonestack(
274 	  *this, "amp.tonestack", N_("Tonestack"), N_("Tone Control"),
275 	  builtin_tonestack_plugins, "amp.tonestack.select",
276 	  _("select"), load_tonestack_ui, 0, PGN_POST_PRE),
277       ampstack(
278 	  *this, "ampstack", _("Amp"), "", builtin_amp_plugins,
279 	  "tube.select", _("select"), 0, ampstack_groups),
280       poweramps(
281 	  *this, "poweramp", _("PowerAmp"), N_("Guitar Effects"), builtin_poweramp_plugins,
282 	  "poweramp.mode", _("select"),load_poweramp_ui , poweramp_groups, PGN_POST_PRE),
283       // internal audio modules
284       noisegate(),
285       monomute(),
286       stereomute(),
287       tuner(*this),
288       drumout(),
289       directout(*this, sigc::mem_fun(mono_chain, &StereoModuleChain::sync)),
290       maxlevel(),
291       oscilloscope(*this),
292       mono_convolver(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync)),
293       stereo_convolver(*this, sigc::mem_fun(stereo_chain, &StereoModuleChain::sync)),
294       cabinet(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync), resamp),
295       cabinet_st(*this, sigc::mem_fun(stereo_chain, &StereoModuleChain::sync), resamp),
296       preamp(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync), resamp),
297       preamp_st(*this, sigc::mem_fun(stereo_chain, &StereoModuleChain::sync), resamp),
298       contrast(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync), resamp),
299       loop(get_param(), sigc::mem_fun(mono_chain,&MonoModuleChain::sync),options.get_loop_dir()),
300       record(*this, 1), record_st(*this, 2),
301       dseq(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync)),
302       detune(*this, sigc::mem_fun(mono_chain, &MonoModuleChain::sync)) {
303     set_overload_interval(options.get_sporadic_overload());
304     if (!options.get_convolver_watchdog()) {
305         ov_disabled |= ov_Convolver;
306     }
307     if (!options.get_watchdog_warning()) {
308         ov_disabled |= ov_NoWarn;
309     }
310     if (!options.get_xrun_watchdog()) {
311         ov_disabled |= ov_XRun;
312     }
313     if (options.get_mute()) {
314         set_state(kEngineOff);;
315     }
316 #ifdef USE_MIDI_OUT
317     tuner.set_dep_module(&midiaudiobuffer.plugin);
318 #endif
319 
320     load_static_plugins();
321     // loaded from shared libs
322     if (!plugin_dir.empty()) {
323 	pluginlist.load_from_path(plugin_dir, PLUGIN_POS_RACK);
324     }
325 
326     for (unsigned int i = 0; i < ladspaloader.size(); ++i) {
327 	PluginDef *p = ladspaloader.create(i);
328 	if (p) {
329 	    pluginlist.add(p);
330 	}
331     }
332 
333     // selector objects to switch "alternative" modules
334     add_selector(ampstack);
335     add_selector(crybaby);
336     add_selector(wah);
337     add_selector(tonestack);
338     add_selector(tuner);
339     add_selector(poweramps);
340 
341     registerParameter(groups);
342 
343 #ifndef NDEBUG
344     pluginlist.printlist();
345 #endif
346 }
347 
~GxEngine()348 GxEngine::~GxEngine() {
349     pluginlist.cleanup();
350 }
351 
load_static_plugins()352 void GxEngine::load_static_plugins() {
353     PluginList& pl = pluginlist; // just a shortcut
354 
355     // * mono amp input position *
356 
357     pl.add(dcblocker::plugin(),                   PLUGIN_POS_START, PGN_MODE_NORMAL|PGN_MODE_BYPASS|PGN_MODE_MUTE);
358     pl.add(&tuner.plugin,                         PLUGIN_POS_START, PGN_PRE|PGN_MODE_NORMAL|PGN_MODE_BYPASS|PGN_MODE_MUTE);
359     pl.add(&noisegate.inputlevel,                 PLUGIN_POS_START, PGN_GUI|PGN_FIXED_GUI|PGN_PRE);
360     pl.add(gx_effects::noise_shaper::plugin(),    PLUGIN_POS_START, PGN_GUI|PGN_FIXED_GUI|PGN_PRE);
361 
362     // rack pre mono modules inserted here
363 
364     pl.add(builtin_amp_plugins,                   PLUGIN_POS_START, PGN_ALTERNATIVE|PGN_POST);
365     pl.add(&ampstack.plugin,                      PLUGIN_POS_START, PGN_POST);
366     pl.add(gx_effects::softclip::plugin(),        PLUGIN_POS_START, PGN_GUI|PGN_FIXED_GUI|PGN_POST);
367 
368     // rack post mono modules inserted here
369 
370     pl.add(gx_effects::bassbooster::plugin(),     PLUGIN_POS_END, PGN_GUI|PGN_FIXED_GUI|PGN_POST);
371     pl.add(gx_effects::gx_ampout::plugin(),       PLUGIN_POS_END, PGN_GUI|PGN_FIXED_GUI|PGN_POST);
372     pl.add(&contrast.plugin,                      PLUGIN_POS_END, PGN_GUI|PGN_FIXED_GUI|PGN_POST);
373     pl.add(&noisegate.outputgate,                 PLUGIN_POS_END, PGN_POST);
374     pl.add(&monomute,                             PLUGIN_POS_END, PGN_POST|PGN_MODE_MUTE);
375 
376     // * amp insert position (stereo amp input) *
377 
378     pl.add(gx_effects::gxfeed::plugin(),          PLUGIN_POS_START);
379 
380     // rack stereo modules inserted here
381 
382     pl.add(gx_effects::gx_outputlevel::plugin(),  PLUGIN_POS_END);
383     pl.add(balance::plugin(),                     PLUGIN_POS_END, PGN_MODE_BYPASS);
384     pl.add(&stereomute,                           PLUGIN_POS_END, PGN_MODE_MUTE);
385     pl.add(fizz_remover::plugin(),                PLUGIN_POS_END, PGN_GUI);
386     pl.add(hardlim::plugin(),                     PLUGIN_POS_END, PGN_MODE_NORMAL);
387     pl.add(&drumout.outputdrum,                   PLUGIN_POS_END, PGN_MODE_NORMAL);
388     pl.add(&directout,                            PLUGIN_POS_END, PGN_MODE_NORMAL);
389     pl.add(&maxlevel,                             PLUGIN_POS_END, PGN_MODE_NORMAL|PGN_MODE_BYPASS);
390 
391     // * fx amp output *
392 
393     // dynamic rack modules
394     // builtin
395     pl.add(builtin_crybaby_plugins,               PLUGIN_POS_RACK, PGN_ALTERNATIVE);
396     pl.add(builtin_wah_plugins,                   PLUGIN_POS_RACK, PGN_ALTERNATIVE);
397     pl.add(builtin_tonestack_plugins,             PLUGIN_POS_RACK, PGN_ALTERNATIVE);
398     pl.add(builtin_poweramp_plugins,              PLUGIN_POS_RACK, PGN_ALTERNATIVE);
399 
400     // mono
401     pl.add(gx_effects::gain::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
402     pl.add(gx_effects::low_high_pass::plugin(),   PLUGIN_POS_RACK, PGN_GUI);
403     pl.add(gx_effects::highbooster::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
404     pl.add(gx_effects::selecteq::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
405     pl.add(&crybaby.plugin,                       PLUGIN_POS_RACK, PGN_GUI);
406     pl.add(&poweramps.plugin,                     PLUGIN_POS_RACK, PGN_GUI);
407     pl.add(&wah.plugin,                           PLUGIN_POS_RACK, PGN_GUI);
408     pl.add(&loop.plugin,                          PLUGIN_POS_RACK, PGN_GUI);
409     pl.add(&record.plugin,                        PLUGIN_POS_RACK, PGN_GUI);
410     pl.add(&detune.plugin,                        PLUGIN_POS_RACK, PGN_GUI);
411     pl.add(&dseq.plugin,                          PLUGIN_POS_RACK, PGN_GUI);
412     pl.add(gx_effects::gx_distortion::plugin(),   PLUGIN_POS_RACK, PGN_GUI);
413     pl.add(gx_effects::bitdowner::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
414     pl.add(gx_effects::thick_distortion::plugin(), PLUGIN_POS_RACK, PGN_GUI);
415     pl.add(pluginlib::ts9sim::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
416     pl.add(pluginlib::aclipper::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
417     pl.add(pluginlib::mxrdist::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
418     pl.add(pluginlib::bossds1::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
419     pl.add(pluginlib::bmp::plugin(),              PLUGIN_POS_RACK, PGN_GUI);
420     pl.add(gx_effects::impulseresponse::plugin(), PLUGIN_POS_RACK, PGN_GUI);
421     pl.add(gx_effects::compressor::plugin(),      PLUGIN_POS_RACK, PGN_GUI);
422     pl.add(gx_effects::expander::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
423     pl.add(gx_effects::overdrive::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
424     pl.add(gx_effects::echo::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
425     pl.add(gx_effects::delay::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
426     pl.add(&mono_convolver.plugin,                PLUGIN_POS_RACK, PGN_GUI);
427     pl.add(gx_effects::freeverb::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
428     pl.add(&oscilloscope.plugin,                  PLUGIN_POS_RACK, PGN_GUI);
429     pl.add(gx_effects::biquad::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
430     pl.add(gx_effects::tremolo::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
431     pl.add(gx_effects::phaser_mono::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
432     pl.add(gx_effects::chorus_mono::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
433     pl.add(gx_effects::flanger_mono::plugin(),    PLUGIN_POS_RACK, PGN_GUI);
434     pl.add(pluginlib::flanger_gx::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
435     pl.add(gx_effects::gx_feedback::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
436     pl.add(gx_effects::peak_eq::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
437     pl.add(gx_effects::digital_delay::plugin(),   PLUGIN_POS_RACK, PGN_GUI);
438     pl.add(&tonestack.plugin,                     PLUGIN_POS_RACK, PGN_GUI);
439     pl.add(&cabinet.plugin,                       PLUGIN_POS_RACK, PGN_GUI);
440     pl.add(&preamp.plugin,                        PLUGIN_POS_RACK, PGN_GUI);
441     pl.add(pluginlib::abgate::plugin(),           PLUGIN_POS_RACK);
442     pl.add(gx_effects::ring_modulator::plugin(),  PLUGIN_POS_RACK, PGN_GUI);
443     pl.add(gx_effects::graphiceq::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
444     pl.add(pluginlib::vibe::plugin_mono(),        PLUGIN_POS_RACK);
445     pl.add(pluginlib::mbc::plugin(),              PLUGIN_POS_RACK, PGN_GUI);
446     pl.add(pluginlib::mbd::plugin(),              PLUGIN_POS_RACK, PGN_GUI);
447     pl.add(pluginlib::mbe::plugin(),              PLUGIN_POS_RACK, PGN_GUI);
448     pl.add(pluginlib::mbdel::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
449     pl.add(pluginlib::mbclipper::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
450     pl.add(pluginlib::bassboom::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
451     pl.add(pluginlib::mbchor::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
452     pl.add(pluginlib::jcm800pre::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
453     pl.add(pluginlib::gcb_95::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
454 	pl.add(gx_effects::duck_delay::plugin(),      PLUGIN_POS_RACK, PGN_GUI);
455 	pl.add(pluginlib::reversedelay::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
456 	pl.add(gx_effects::baxandall::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
457 	pl.add(gx_effects::distortion2::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
458 	pl.add(gx_effects::fuzzface::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
459 	pl.add(gx_effects::trbuff::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
460 	pl.add(pluginlib::fuzzfacefm::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
461 	pl.add(pluginlib::fuzzfacerm::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
462 	pl.add(pluginlib::hornet::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
463 	pl.add(pluginlib::susta::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
464 	pl.add(pluginlib::hfb::plugin(),              PLUGIN_POS_RACK, PGN_GUI);
465 	pl.add(pluginlib::muff::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
466 	pl.add(pluginlib::scream::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
467 	pl.add(pluginlib::lpbboost::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
468 	pl.add(pluginlib::foxeylady::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
469 	pl.add(pluginlib::hogsfoot::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
470 	pl.add(pluginlib::cstb::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
471 	pl.add(pluginlib::coverd::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
472 	pl.add(pluginlib::rangem::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
473 	pl.add(pluginlib::ruin::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
474 	pl.add(pluginlib::ffreak::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
475 	pl.add(pluginlib::fumaster::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
476 	pl.add(pluginlib::fuzzdrive::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
477 	pl.add(pluginlib::rolandwah::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
478 	pl.add(pluginlib::astrofuzz::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
479 	pl.add(pluginlib::buffb::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
480 	pl.add(pluginlib::eldist::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
481 	pl.add(pluginlib::mole::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
482 	pl.add(pluginlib::buzz::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
483 	pl.add(pluginlib::bfuzz::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
484 	pl.add(pluginlib::axface::plugin(),           PLUGIN_POS_RACK, PGN_GUI);
485 	pl.add(pluginlib::metronome::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
486 	pl.add(pluginlib::vumeter::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
487     // stereo
488     pl.add(gx_effects::chorus::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
489     pl.add(gx_effects::flanger::plugin(),         PLUGIN_POS_RACK, PGN_GUI);
490     pl.add(gx_effects::phaser::plugin(),          PLUGIN_POS_RACK, PGN_GUI);
491     pl.add(gx_effects::stereodelay::plugin(),     PLUGIN_POS_RACK, PGN_GUI);
492     pl.add(gx_effects::stereoecho::plugin(),      PLUGIN_POS_RACK, PGN_GUI);
493     pl.add(gx_effects::moog::plugin(),            PLUGIN_POS_RACK, PGN_GUI);
494     pl.add(gx_amps::gx_ampmodul::plugin(),        PLUGIN_POS_RACK, PGN_GUI);
495     pl.add(gx_effects::tonecontroll::plugin(),    PLUGIN_POS_RACK, PGN_GUI);
496     pl.add(gx_effects::digital_delay_st::plugin(),PLUGIN_POS_RACK, PGN_GUI);
497     pl.add(&stereo_convolver.plugin,              PLUGIN_POS_RACK, PGN_GUI);
498     pl.add(&record_st.plugin,                     PLUGIN_POS_RACK, PGN_GUI);
499     pl.add(gx_effects::stereoverb::plugin(),      PLUGIN_POS_RACK, PGN_GUI);
500     pl.add(pluginlib::zita_rev1::plugin(),        PLUGIN_POS_RACK);
501     pl.add(pluginlib::vibe::plugin_stereo(),      PLUGIN_POS_RACK);
502     pl.add(pluginlib::mbcs::plugin(),             PLUGIN_POS_RACK, PGN_GUI);
503     pl.add(gx_effects::dattorros_progenitor::plugin(),PLUGIN_POS_RACK, PGN_GUI);
504     pl.add(gx_effects::panoram_enhancer::plugin(),PLUGIN_POS_RACK, PGN_GUI);
505     pl.add(gx_effects::bass_enhancer::plugin(),   PLUGIN_POS_RACK, PGN_GUI);
506     pl.add(gx_effects::ring_modulator_st::plugin(),PLUGIN_POS_RACK, PGN_GUI);
507 	pl.add(gx_effects::duck_delay_st::plugin(),   PLUGIN_POS_RACK, PGN_GUI);
508     pl.add(&cabinet_st.plugin,                    PLUGIN_POS_RACK, PGN_GUI);
509     pl.add(&preamp_st.plugin,                     PLUGIN_POS_RACK, PGN_GUI);
510 	pl.add(pluginlib::vumeter_st::plugin(),       PLUGIN_POS_RACK, PGN_GUI);
511 }
512 
find_plugin(LadspaLoader::pluginarray & ml,plugdesc * pl)513 static LadspaLoader::pluginarray::iterator find_plugin(LadspaLoader::pluginarray& ml, plugdesc *pl) {
514     for (LadspaLoader::pluginarray::iterator i = ml.begin(); i != ml.end(); ++i) {
515 	if (pl->quirks & is_lv2) {
516 	    if ((*i)->path == pl->path) {
517 		return i;
518 	    }
519 	} else {
520 	    if ((*i)->UniqueID == pl->UniqueID) {
521 		return i;
522 	    }
523 	}
524     }
525     return ml.end();
526 }
527 
ladspaloader_update_plugins()528 void GxEngine::ladspaloader_update_plugins() {
529     // load plugindesc list
530     LadspaLoader::pluginarray ml;
531     ladspaloader.load(ml);
532     // look for removed and changed plugins
533     std::vector<PluginChange> pv;
534     for (LadspaLoader::pluginarray::iterator i = ladspaloader.begin(); i != ladspaloader.end(); ++i) {
535 	Plugin *pl = pluginlist.lookup_plugin((*i)->id_str);
536 	LadspaLoader::pluginarray::iterator j = find_plugin(ml, *i);
537 	if (j == ml.end()) {
538 	    pl->set_on_off(false);
539 	    pv.push_back(PluginChange(pl, PluginChange::remove));
540 	} else {
541 	    ladspaloader.update_instance(pl->get_pdef(), *j);
542 	    if (pl->get_pdef()->register_params) {
543 		pmap.set_replace_mode(true);
544 		gx_engine::ParamRegImpl preg(&pmap);
545         // FIXME we need to register on_off parameters new when ui is changed
546         bool state = pl->get_on_off();
547         pluginlist.rescueParameter(pl, pmap);
548         pl->set_on_off(state);
549 		preg.plugin = pl->get_pdef();
550 		pl->get_pdef()->register_params(preg);
551 		pmap.set_replace_mode(false);
552 	    }
553 	    pv.push_back(
554 		PluginChange(
555 		    pl,
556 		    ((*j)->category == (*i)->category ? PluginChange::update : PluginChange::update_category)));
557 	}
558     }
559 
560     // update engine for plugins to be removed
561     update_module_lists();
562     mono_chain.release();
563     stereo_chain.release();
564     // remove plugins
565     for (std::vector<PluginChange>::iterator i = pv.begin(); i != pv.end(); ++i) {
566 	if (i->status == PluginChange::remove) {
567 	    plugin_changed(i->pl, PluginChange::remove);
568 	    pluginlist.unregisterPlugin(i->pl, pmap, get_group_table());
569 	    pluginlist.delete_module(i->pl);
570 	} else {
571 	    plugin_changed(i->pl, i->status);
572 	}
573     }
574     // add new plugins (engine)
575     for (LadspaLoader::pluginarray::const_iterator i = ml.begin(); i != ml.end(); ++i) {
576 	if (ladspaloader.find(*i) == ladspaloader.end()) {
577 	    PluginDef *plugin = ladspaloader.create(*i);
578 	    if (plugin) {
579 		Plugin *p = pluginlist.add(plugin);
580 		pluginlist.registerPlugin(p, get_param(), get_group_table());
581 		plugin->set_samplerate(get_samplerate(), plugin);
582 		plugin_changed(p, PluginChange::add);
583 	    }
584 	}
585     }
586     // update ladspaloader with new list
587     ladspaloader.set_plugins(ml);
588     plugin_changed(0, PluginChange::update);
589 }
590 
591 } /* end of gx_engine namespace */
592