2016-05-19 10:29:39 -04:00
|
|
|
/*
|
2023-01-05 18:53:22 -05:00
|
|
|
* Copyright (C) 2016-2023 Robin Gareus <robin@gareus.org>
|
2016-05-19 10:29:39 -04:00
|
|
|
*
|
2019-08-02 17:26:43 -04:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2016-05-19 10:29:39 -04:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2019-08-02 17:26:43 -04:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2016-05-19 10:29:39 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gtkmm/frame.h>
|
|
|
|
#include <gtkmm/label.h>
|
2017-07-16 22:55:52 -04:00
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
#include <gtkmm/table.h>
|
2016-05-19 10:29:39 -04:00
|
|
|
|
|
|
|
#include "plugin_setup_dialog.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2016-05-19 10:29:39 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2017-07-15 11:38:28 -04:00
|
|
|
using namespace ArdourWidgets;
|
2016-05-19 10:29:39 -04:00
|
|
|
using namespace Gtk;
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
PluginSetupDialog::PluginSetupDialog (std::shared_ptr<ARDOUR::Route> r, std::shared_ptr<ARDOUR::PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
|
2016-05-19 10:29:39 -04:00
|
|
|
: ArdourDialog (_("Plugin Setup"), true, false)
|
|
|
|
, _route (r)
|
|
|
|
, _pi (pi)
|
|
|
|
, _keep_mapping (_("Copy I/O Map"), ArdourButton::led_default_elements)
|
2017-01-20 18:40:18 -05:00
|
|
|
, _fan_out (_("Fan out"), ArdourButton::led_default_elements)
|
2016-05-19 10:29:39 -04:00
|
|
|
{
|
|
|
|
assert (flags != Route::None);
|
|
|
|
|
|
|
|
Gtk::Table *tbl = manage (new Gtk::Table ());
|
|
|
|
tbl->set_spacings (6);
|
|
|
|
get_vbox()->pack_start (*tbl);
|
|
|
|
int row = 0;
|
|
|
|
|
|
|
|
if (flags & Route::CanReplace) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Processor> old = _route->the_instrument ();
|
|
|
|
std::shared_ptr<PluginInsert> opi = std::dynamic_pointer_cast<PluginInsert> (old);
|
2016-05-19 10:29:39 -04:00
|
|
|
assert (opi);
|
|
|
|
|
|
|
|
opi->configured_io (_cur_inputs, _cur_outputs);
|
|
|
|
|
|
|
|
Gtk::Label* l = manage (new Label (
|
|
|
|
_("An Instrument plugin is already present.")
|
|
|
|
));
|
|
|
|
tbl->attach (*l, 0, 2, row, row + 1, EXPAND|FILL, SHRINK); ++row;
|
|
|
|
|
|
|
|
l = manage (new Label (_("Replace"), ALIGN_END));
|
|
|
|
tbl->attach (*l, 0, 1, row, row + 1, EXPAND|FILL, SHRINK);
|
|
|
|
|
|
|
|
l = manage (new Label (string_compose ("'%1'", old->name ()), ALIGN_START));
|
|
|
|
tbl->attach (*l, 1, 2, row, row + 1, EXPAND|FILL, SHRINK); ++row;
|
|
|
|
|
|
|
|
l = manage (new Label (_("with"), ALIGN_END));
|
|
|
|
tbl->attach (*l, 0, 1, row, row + 1, EXPAND|FILL, SHRINK);
|
|
|
|
|
|
|
|
l = manage (new Label (string_compose ("'%1'", pi->name ()), ALIGN_START));
|
|
|
|
tbl->attach (*l, 1, 2, row, row + 1, EXPAND|FILL, SHRINK); ++row;
|
|
|
|
|
|
|
|
Box* box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_keep_mapping, true, true);
|
|
|
|
Frame* f = manage (new Frame ());
|
|
|
|
f->set_label (_("I/O Pin Mapping"));
|
|
|
|
f->add (*box);
|
|
|
|
tbl->attach (*f, 0, 1, row, row + 1, EXPAND|FILL, SHRINK, 0, 8);
|
|
|
|
|
2017-01-20 18:40:18 -05:00
|
|
|
_keep_mapping.signal_clicked.connect (sigc::mem_fun (*this, &PluginSetupDialog::apply_mapping));
|
2020-06-17 13:04:40 -04:00
|
|
|
add_button (_("Replace"), 2);
|
2016-05-19 10:29:39 -04:00
|
|
|
} else {
|
|
|
|
|
|
|
|
Gtk::Label *l = manage (new Label (string_compose (
|
|
|
|
_("Configure Plugin '%1'"), pi->name ()
|
|
|
|
)));
|
|
|
|
tbl->attach (*l, 0, 2, row, row + 1, EXPAND|FILL, SHRINK); ++row;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & Route::MultiOut) {
|
|
|
|
setup_output_presets ();
|
|
|
|
Box* box = manage (new HBox ());
|
|
|
|
box->set_border_width (2);
|
|
|
|
box->pack_start (_out_presets, true, true);
|
2017-01-20 18:40:18 -05:00
|
|
|
box->pack_start (_fan_out, false, false);
|
2016-05-19 10:29:39 -04:00
|
|
|
Frame* f = manage (new Frame ());
|
|
|
|
f->set_label (_("Output Configuration"));
|
|
|
|
f->add (*box);
|
|
|
|
tbl->attach (*f, 1, 2, row, row + 1, EXPAND|FILL, SHRINK, 0, 8);
|
2017-01-20 18:40:18 -05:00
|
|
|
_fan_out.signal_clicked.connect (sigc::mem_fun (*this, &PluginSetupDialog::toggle_fan_out));
|
2019-11-02 11:33:14 -04:00
|
|
|
_fan_out.set_active (true);
|
2016-05-19 10:29:39 -04:00
|
|
|
} else {
|
|
|
|
_pi->set_preset_out (_pi->natural_output_streams ());
|
|
|
|
update_sensitivity (_pi->natural_output_streams ().n_audio ());
|
2019-11-02 11:33:14 -04:00
|
|
|
_fan_out.set_active (false);
|
2016-05-19 10:29:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_keep_mapping.set_active (false);
|
|
|
|
apply_mapping ();
|
|
|
|
|
|
|
|
add_button (Stock::ADD, 0);
|
|
|
|
add_button (Stock::CANCEL, 1);
|
|
|
|
set_default_response (0);
|
|
|
|
show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSetupDialog::setup_output_presets ()
|
|
|
|
{
|
|
|
|
// compare to PluginPinDialog::refill_output_presets ()
|
|
|
|
using namespace Menu_Helpers;
|
|
|
|
PluginOutputConfiguration ppc (_pi->plugin (0)->possible_output ());
|
|
|
|
|
|
|
|
_out_presets.AddMenuElem (MenuElem (_("Automatic"), sigc::bind (sigc::mem_fun (*this, &PluginSetupDialog::select_output_preset), 0)));
|
|
|
|
|
|
|
|
if (ppc.find (0) != ppc.end ()) {
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
// anything goes
|
2016-05-19 10:29:39 -04:00
|
|
|
ppc.clear ();
|
|
|
|
ppc.insert (1);
|
|
|
|
ppc.insert (2);
|
|
|
|
ppc.insert (8);
|
|
|
|
ppc.insert (16);
|
|
|
|
ppc.insert (24);
|
|
|
|
ppc.insert (32);
|
|
|
|
if (ppc.find (_cur_outputs.n_audio ()) == ppc.end ()) {
|
|
|
|
ppc.insert (_cur_outputs.n_audio ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-05 18:53:34 -05:00
|
|
|
const uint32_t n_audio = _cur_outputs.n_audio ();
|
|
|
|
|
|
|
|
bool have_matching_io = ppc.find (n_audio) != ppc.end ();
|
|
|
|
if (have_matching_io) {
|
|
|
|
_out_presets.AddMenuElem (MenuElem (preset_label (n_audio), sigc::bind (sigc::mem_fun (*this, &PluginSetupDialog::select_output_preset), n_audio)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ppc.size() > 6 && *ppc.rbegin () != n_audio) {
|
|
|
|
uint32_t all = *ppc.rbegin ();
|
|
|
|
_out_presets.AddMenuElem (MenuElem (string_compose (_("All (%1)"), preset_label (all)), sigc::bind (sigc::mem_fun (*this, &PluginSetupDialog::select_output_preset), all)));
|
|
|
|
ppc.erase (all);
|
|
|
|
}
|
2016-05-19 10:29:39 -04:00
|
|
|
|
|
|
|
for (PluginOutputConfiguration::const_iterator i = ppc.begin () ; i != ppc.end (); ++i) {
|
|
|
|
assert (*i > 0);
|
2023-01-05 18:53:34 -05:00
|
|
|
if (*i == n_audio) {
|
|
|
|
assert (have_matching_io);
|
|
|
|
continue;
|
|
|
|
}
|
2016-05-19 10:29:39 -04:00
|
|
|
_out_presets.AddMenuElem (MenuElem (preset_label (*i), sigc::bind (sigc::mem_fun (*this, &PluginSetupDialog::select_output_preset), *i)));
|
2023-01-05 18:53:34 -05:00
|
|
|
if (_out_presets.items ().size () > 6) {
|
|
|
|
break;
|
2016-05-19 10:29:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_matching_io) {
|
|
|
|
select_output_preset (_cur_outputs.n_audio ());
|
2019-10-30 10:35:23 -04:00
|
|
|
} else if (ppc.size() == 1 && _pi->strict_io ()) {
|
|
|
|
select_output_preset (*ppc.begin ());
|
2016-05-19 10:29:39 -04:00
|
|
|
} else {
|
|
|
|
select_output_preset (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSetupDialog::select_output_preset (uint32_t n_audio)
|
|
|
|
{
|
|
|
|
_pi->set_preset_out (ChanCount (DataType::AUDIO, n_audio));
|
|
|
|
_out_presets.set_text (preset_label (n_audio));
|
|
|
|
update_sensitivity (n_audio);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSetupDialog::update_sensitivity (uint32_t n_audio)
|
|
|
|
{
|
|
|
|
if (_cur_outputs.n_audio () > 0 && _cur_outputs.n_audio () == n_audio) {
|
|
|
|
// TODO check _cur_inputs if not reconfigurable?
|
|
|
|
_keep_mapping.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
_keep_mapping.set_sensitive (false);
|
|
|
|
}
|
2017-01-20 18:40:18 -05:00
|
|
|
_fan_out.set_sensitive (n_audio > 2);
|
2016-05-19 10:29:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginSetupDialog::io_match () const
|
|
|
|
{
|
|
|
|
if (_cur_outputs.n_audio () > 0 && _cur_outputs.n_audio () == _pi->preset_out ().n_audio ()) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSetupDialog::apply_mapping ()
|
|
|
|
{
|
|
|
|
// toggle button
|
|
|
|
_keep_mapping.set_active (!_keep_mapping.get_active ());
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Processor> old = _route->the_instrument ();
|
|
|
|
std::shared_ptr<PluginInsert> opi = std::dynamic_pointer_cast<PluginInsert> (old);
|
2016-05-19 10:29:39 -04:00
|
|
|
|
|
|
|
if (_keep_mapping.get_active () && opi && io_match ()) {
|
|
|
|
_pi->pre_seed (_cur_inputs, _cur_outputs, opi->input_map (0), opi->output_map (0), opi->thru_map ());
|
|
|
|
} else {
|
|
|
|
_pi->pre_seed (ChanCount (), ChanCount (), ChanMapping (), ChanMapping (), ChanMapping());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-20 18:40:18 -05:00
|
|
|
void
|
|
|
|
PluginSetupDialog::toggle_fan_out ()
|
|
|
|
{
|
|
|
|
_fan_out.set_active (!_fan_out.get_active ());
|
|
|
|
}
|
|
|
|
|
2016-05-19 10:29:39 -04:00
|
|
|
std::string
|
2023-01-05 18:53:22 -05:00
|
|
|
PluginSetupDialog::preset_label (uint32_t n_audio)
|
2016-05-19 10:29:39 -04:00
|
|
|
{
|
|
|
|
std::string rv;
|
|
|
|
switch (n_audio) {
|
|
|
|
case 0:
|
|
|
|
rv = _("Automatic");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
rv = _("Mono");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rv = _("Stereo");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rv = string_compose (P_("%1 Channel", "%1 Channels", n_audio), n_audio);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|