13
0

Output Port Presets.

This commit is contained in:
Robin Gareus 2016-04-15 18:15:05 +02:00
parent 424cacfbc8
commit 5242aeb871
2 changed files with 90 additions and 2 deletions

View File

@ -50,7 +50,7 @@ using namespace Gtkmm2ext;
PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi) PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
: ArdourWindow (string_compose (_("Pin Configuration: %1"), pi->name ())) : ArdourWindow (string_compose (_("Pin Configuration: %1"), pi->name ()))
, _set_config (_("Configure"), ArdourButton::led_default_elements) , _set_config (_("Manual Config"), ArdourButton::led_default_elements)
, _tgl_sidechain (_("Side Chain"), ArdourButton::led_default_elements) , _tgl_sidechain (_("Side Chain"), ArdourButton::led_default_elements)
, _add_plugin (_("+")) , _add_plugin (_("+"))
, _del_plugin (_("-")) , _del_plugin (_("-"))
@ -125,7 +125,6 @@ PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
/* left side */ /* left side */
tl->pack_start (_set_config, false, false); tl->pack_start (_set_config, false, false);
tl->pack_start (*manage (new Label ("")), true, true); // invisible separator
box = manage (new HBox ()); box = manage (new HBox ());
box->set_border_width (2); box->set_border_width (2);
@ -154,6 +153,11 @@ PluginPinDialog::PluginPinDialog (boost::shared_ptr<ARDOUR::PluginInsert> pi)
f->add (*box); f->add (*box);
tl->pack_start (*f, false, false); tl->pack_start (*f, false, false);
tl->pack_start (*manage (new Label ("")), true, true); // invisible separator
tl->pack_start (*manage (new HSeparator ()), false, false, 4);
_out_presets.disable_scrolling ();
ARDOUR_UI_UTILS::set_tooltip (_out_presets, _("Output Presets"));
tl->pack_start (_out_presets, false, false);
/* right side */ /* right side */
_sidechain_tbl = manage (new Gtk::Table ()); _sidechain_tbl = manage (new Gtk::Table ());
@ -232,6 +236,7 @@ PluginPinDialog::plugin_reconfigured ()
_sinks = _pi->natural_input_streams (); _sinks = _pi->natural_input_streams ();
_sources = _pi->natural_output_streams (); _sources = _pi->natural_output_streams ();
_tgl_sidechain.set_active (_pi->has_sidechain ()); _tgl_sidechain.set_active (_pi->has_sidechain ());
_add_sc_audio.set_sensitive (_pi->has_sidechain ()); _add_sc_audio.set_sensitive (_pi->has_sidechain ());
_add_sc_midi.set_sensitive (_pi->has_sidechain ()); _add_sc_midi.set_sensitive (_pi->has_sidechain ());
@ -244,6 +249,8 @@ PluginPinDialog::plugin_reconfigured ()
_del_plugin.set_sensitive (_n_plugins > 1); _del_plugin.set_sensitive (_n_plugins > 1);
_del_output_audio.set_sensitive (_out.n_audio () > 0 && _out.n_total () > 1); _del_output_audio.set_sensitive (_out.n_audio () > 0 && _out.n_total () > 1);
_del_output_midi.set_sensitive (_out.n_midi () > 0 && _out.n_total () > 1); _del_output_midi.set_sensitive (_out.n_midi () > 0 && _out.n_total () > 1);
_out_presets.set_sensitive (false);
_out_presets.set_text (_("Manual"));
} else { } else {
_set_config.set_active (false); _set_config.set_active (false);
_add_plugin.set_sensitive (false); _add_plugin.set_sensitive (false);
@ -252,6 +259,8 @@ PluginPinDialog::plugin_reconfigured ()
_del_plugin.set_sensitive (false); _del_plugin.set_sensitive (false);
_del_output_audio.set_sensitive (false); _del_output_audio.set_sensitive (false);
_del_output_midi.set_sensitive (false); _del_output_midi.set_sensitive (false);
_out_presets.set_sensitive (true);
refill_output_presets ();
} }
if (!_pi->has_sidechain () && _sidechain_selector) { if (!_pi->has_sidechain () && _sidechain_selector) {
@ -359,6 +368,55 @@ PluginPinDialog::refill_sidechain_table ()
_sidechain_tbl->show_all (); _sidechain_tbl->show_all ();
} }
void
PluginPinDialog::refill_output_presets ()
{
using namespace Menu_Helpers;
_out_presets.clear_items();
_out_presets.AddMenuElem (MenuElem(_("Automatic"), sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::select_output_preset), 0)));
PluginOutputConfiguration ppc (_pi->plugin (0)->possible_output ());
const uint32_t n_audio = _pi->preset_out ().n_audio ();
if (n_audio == 0) {
_out_presets.set_text(_("Automatic"));
}
if (ppc.find (0) != ppc.end ()) {
// anyting goes
ppc.clear ();
if (n_audio != 0) {
ppc.insert (n_audio);
}
ppc.insert (1);
ppc.insert (2);
ppc.insert (8);
ppc.insert (16);
ppc.insert (24);
ppc.insert (32);
}
for (PluginOutputConfiguration::const_iterator i = ppc.begin () ; i != ppc.end (); ++i) {
assert (*i > 0);
std::string tmp;
switch (*i) {
case 1:
tmp = _("Mono");
break;
case 2:
tmp = _("Stereo");
break;
default:
tmp = string_compose (P_("%1 Channel", "%1 Channels", *i), *i);
break;
}
_out_presets.AddMenuElem (MenuElem(tmp, sigc::bind (sigc::mem_fun (*this, &PluginPinDialog::select_output_preset), *i)));
if (n_audio == *i) {
_out_presets.set_text(tmp);
}
}
}
void void
PluginPinDialog::add_port_to_table (boost::shared_ptr<Port> p, uint32_t r, bool can_remove) PluginPinDialog::add_port_to_table (boost::shared_ptr<Port> p, uint32_t r, bool can_remove)
{ {
@ -777,6 +835,16 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
cairo_set_source_rgba (cr, 1., 1., 1., 1.); cairo_set_source_rgba (cr, 1., 1., 1., 1.);
pango_cairo_show_layout (cr, layout->gobj ()); pango_cairo_show_layout (cr, layout->gobj ());
if (_pi->signal_latency () > 0) {
// TODO: this needs a better location also format to msec (and cache)
layout->set_width ((_innerwidth - 2 * _pin_box_size) * PANGO_SCALE);
layout->set_text (string_compose (_("Latency %1 spl"), _pi->signal_latency ()));
layout->get_pixel_size (text_width, text_height);
cairo_move_to (cr, _margin_x + _pin_box_size * .5, _margin_y + 2);
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
pango_cairo_show_layout (cr, layout->gobj ());
}
if (_pi->strict_io () && !Profile->get_mixbus ()) { if (_pi->strict_io () && !Profile->get_mixbus ()) {
layout->set_text (_("Strict I/O")); layout->set_text (_("Strict I/O"));
layout->get_pixel_size (text_width, text_height); layout->get_pixel_size (text_width, text_height);
@ -803,6 +871,13 @@ PluginPinDialog::darea_expose_event (GdkEventExpose* ev)
rounded_rectangle (cr, x0 - _bxw2, yc - _bxh2, 2 * _bxw2, 2 * _bxh2, 7); rounded_rectangle (cr, x0 - _bxw2, yc - _bxh2, 2 * _bxw2, 2 * _bxh2, 7);
cairo_fill (cr); cairo_fill (cr);
layout->set_width (1.9 * _bxw2 * PANGO_SCALE);
layout->set_text (string_compose (_("Plugin #%1"), i + 1));
layout->get_pixel_size (text_width, text_height);
cairo_move_to (cr, x0 - text_width * .5, yc - text_height * .5);
cairo_set_source_rgba (cr, 1., 1., 1., 1.);
pango_cairo_show_layout (cr, layout->gobj ());
const ChanMapping::Mappings in_map = _pi->input_map (i).mappings (); const ChanMapping::Mappings in_map = _pi->input_map (i).mappings ();
const ChanMapping::Mappings out_map = _pi->output_map (i).mappings (); const ChanMapping::Mappings out_map = _pi->output_map (i).mappings ();
@ -1328,6 +1403,14 @@ PluginPinDialog::reset_mapping ()
_pi->reset_map (); _pi->reset_map ();
} }
void
PluginPinDialog::select_output_preset (uint32_t n_audio)
{
if (_session && _session->actively_recording()) { return; }
ChanCount out (DataType::AUDIO, n_audio);
_route ()->plugin_preset_output (_pi, out);
}
void void
PluginPinDialog::add_remove_plugin_clicked (bool add) PluginPinDialog::add_remove_plugin_clicked (bool add)
{ {

View File

@ -28,6 +28,7 @@
#include "ardour/route.h" #include "ardour/route.h"
#include "ardour_button.h" #include "ardour_button.h"
#include "ardour_dropdown.h"
#include "ardour_window.h" #include "ardour_window.h"
#include "io_selector.h" #include "io_selector.h"
@ -91,6 +92,8 @@ private:
ArdourButton _add_sc_audio; ArdourButton _add_sc_audio;
ArdourButton _add_sc_midi; ArdourButton _add_sc_midi;
ArdourDropdown _out_presets;
Gtk::Menu reset_menu; Gtk::Menu reset_menu;
Gtk::Menu input_menu; Gtk::Menu input_menu;
Gtk::Table* _sidechain_tbl; Gtk::Table* _sidechain_tbl;
@ -99,6 +102,7 @@ private:
void plugin_reconfigured (); void plugin_reconfigured ();
void update_element_pos (); void update_element_pos ();
void refill_sidechain_table (); void refill_sidechain_table ();
void refill_output_presets ();
void darea_size_request (Gtk::Requisition*); void darea_size_request (Gtk::Requisition*);
void darea_size_allocate (Gtk::Allocation&); void darea_size_allocate (Gtk::Allocation&);
@ -127,6 +131,7 @@ private:
void add_remove_plugin_clicked (bool); void add_remove_plugin_clicked (bool);
void add_remove_port_clicked (bool, ARDOUR::DataType); void add_remove_port_clicked (bool, ARDOUR::DataType);
void add_sidechain_port (ARDOUR::DataType); void add_sidechain_port (ARDOUR::DataType);
void select_output_preset (uint32_t n_audio);
void handle_input_action (const CtrlElem &, const CtrlElem &); void handle_input_action (const CtrlElem &, const CtrlElem &);
void handle_output_action (const CtrlElem &, const CtrlElem &); void handle_output_action (const CtrlElem &, const CtrlElem &);
void handle_thru_action (const CtrlElem &, const CtrlElem &); void handle_thru_action (const CtrlElem &, const CtrlElem &);