#include "gtk2ardour-config.h"
#endif
-#ifdef COMPILER_MSVC
-#define rintf(x) round((x) + 0.5)
-#endif
-
#include <cmath>
#include <iostream>
#include <set>
#include "ardour/audioengine.h"
#include "ardour/internal_return.h"
#include "ardour/internal_send.h"
+#include "ardour/meter.h"
#include "ardour/panner_shell.h"
#include "ardour/plugin_insert.h"
#include "ardour/pannable.h"
ProcessorBox* ProcessorBox::_current_processor_box = 0;
RefPtr<Action> ProcessorBox::paste_action;
RefPtr<Action> ProcessorBox::cut_action;
+RefPtr<Action> ProcessorBox::copy_action;
RefPtr<Action> ProcessorBox::rename_action;
+RefPtr<Action> ProcessorBox::delete_action;
RefPtr<Action> ProcessorBox::edit_action;
RefPtr<Action> ProcessorBox::edit_generic_action;
, _position (PreFader)
, _position_num(0)
, _selectable(true)
+ , _unknown_processor(false)
, _parent (parent)
, _processor (p)
, _width (w)
_button.signal_led_clicked.connect (sigc::mem_fun (*this, &ProcessorEntry::led_clicked));
_button.set_text (name (_width));
+ if (boost::dynamic_pointer_cast<PeakMeter> (_processor)) {
+ _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
+ }
+ if (boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
+ _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
+ _unknown_processor = true;
+ }
if (_processor) {
_vbox.pack_start (_routing_icon);
void
ProcessorEntry::setup_visuals ()
{
+ if (_unknown_processor) {
+ _button.set_name ("processor stub");
+ return;
+ }
+
switch (_position) {
case PreFader:
_button.set_name ("processor prefader");
}
return;
}
+ if(boost::dynamic_pointer_cast<UnknownProcessor> (_processor)) {
+ ARDOUR_UI::instance()->set_tip (_button,
+ string_compose (_("<b>%1</b>\nThe Plugin is not available on this system\nand has been replaced by a stub."), name (Wide)));
+ return;
+ }
}
ARDOUR_UI::instance()->set_tip (_button, string_compose ("<b>%1</b>", name (Wide)));
}
ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n)
: _control (c)
, _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
- , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, 13)
+ , _slider (&_adjustment, boost::shared_ptr<PBD::Controllable>(), 0, max(13.f, rintf(13.f * ARDOUR_UI::ui_scale)))
, _slider_persistant_tooltip (&_slider)
, _button (ArdourButton::led_default_elements)
, _ignore_ui_adjustment (false)
_button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
_button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
- c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
+ // dup. currently timers are used :(
+ //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
} else {
_slider.set_default_value (normal);
_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted));
- c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
+ // dup. currently timers are used :(
+ //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
}
- Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
+ // yuck, do we really need to do this?
+ // according to c404374 this is only needed for send automation
+ timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &Control::control_changed));
control_changed ();
set_tooltip ();
set_no_tooltip_whatsoever (_slider);
}
+ProcessorEntry::Control::~Control ()
+{
+ timer_connection.disconnect ();
+}
+
void
ProcessorEntry::Control::set_tooltip ()
{
if (!c) {
return;
}
-
- stringstream s;
- s << _name << ": ";
+ char tmp[256];
if (c->toggled ()) {
- s << (c->get_value() > 0.5 ? _("on") : _("off"));
+ snprintf (tmp, sizeof(tmp), "%s: %s", _name.c_str(), c->get_value() > 0.5 ? _("on") : _("off"));
} else {
- s << setprecision(2) << fixed;
- s << c->internal_to_user (c->get_value ());
+ snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
}
- string sm = Glib::Markup::escape_text (s.str());
-
+ string sm = Glib::Markup::escape_text (tmp);
_slider_persistant_tooltip.set_tip (sm);
ARDOUR_UI::instance()->set_tip (_button, sm);
}
_button.set_active (c->get_value() > 0.5);
} else {
-
- _adjustment.set_value (c->internal_to_interface(c->get_value ()));
- set_tooltip ();
+ // as long as rapid timers are used, only update the tooltip
+ // if the value has changed.
+ const double nval = c->internal_to_interface (c->get_value ());
+ if (_adjustment.get_value() != nval) {
+ _adjustment.set_value (nval);
+ set_tooltip ();
+ }
}
_ignore_ui_adjustment = false;
void
PluginInsertProcessorEntry::plugin_insert_splitting_changed ()
{
- _output_icon.set_ports(_plugin_insert->output_streams());
- _routing_icon.set_splitting(_plugin_insert->splitting ());
+ ChanCount in, out; // actual configured i/o
+ _plugin_insert->configured_io (in, out);
- ChanCount sources = _plugin_insert->input_streams();
+ /* get number of input ports */
ChanCount sinks = _plugin_insert->natural_input_streams();
-
- /* replicated instances */
if (!_plugin_insert->splitting () && _plugin_insert->get_count() > 1) {
+ /* replicated instances */
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
sinks.set(*t, sinks.get(*t) * _plugin_insert->get_count());
}
/* MIDI bypass */
if (_plugin_insert->natural_output_streams().n_midi() == 0 &&
_plugin_insert->output_streams().n_midi() == 1) {
+ in.set(DataType::MIDI, 1);
+ out.set(DataType::MIDI, 1);
sinks.set(DataType::MIDI, 1);
- sources.set(DataType::MIDI, 1);
}
+ /* the Input streams available (*valid* outputs from prev. plugin)
+ * this will be <= sinks. Some input-ports of this processor
+ * may be unconnected.
+ */
+ _routing_icon.set_sources(in);
+
+ /* the actual input ports of this processor */
_input_icon.set_ports(sinks);
_routing_icon.set_sinks(sinks);
- _routing_icon.set_sources(sources);
- if (_plugin_insert->splitting () ||
- _plugin_insert->input_streams().n_audio() < _plugin_insert->natural_input_streams().n_audio()
- )
+ /* set/override plugin-output ports to actual outputs-streams.
+ *
+ * This plugin may have unconnected output-ports (currently only in Mixbus,
+ * e.g channelstrip-EQ at the top of a MIDI-channel before the synth).
+ *
+ * The *next* processor below this one will only see the
+ * actual available streams (it cannot know the real outputs
+ * of this plugin).
+ *
+ * There is currently no API to query the ports of the previous (or next)
+ * processor.
+ *
+ * (normally - iff configuration succeeds - this is set during
+ * ProcessorEntry::processor_configuration_changed() and should
+ * equal _plugin_insert->output_streams())
+ */
+ _output_icon.set_ports(out);
+#ifndef NDEBUG
+ if (out != _plugin_insert->output_streams()) {
+ std::cerr << "Processor Wiring: " << processor()->name()
+ << " out-ports: " << _plugin_insert->output_streams() // NB. does not include midi-bypass
+ << " out-connections: " << out
+ << endmsg;
+ }
+#endif
+
+ _routing_icon.set_splitting(_plugin_insert->splitting ());
+
+ if (_plugin_insert->splitting () || in != sinks)
{
- _routing_icon.set_size_request (-1, 7);
+ _routing_icon.set_size_request (-1, std::max (7.f, rintf(7.f * ARDOUR_UI::ui_scale)));
_routing_icon.set_visible(true);
_input_icon.show();
} else {
plugin_insert_splitting_changed ();
}
+ProcessorEntry::PortIcon::PortIcon(bool input) {
+ _input = input;
+ _ports = ARDOUR::ChanCount(ARDOUR::DataType::AUDIO, 1);
+ set_size_request (-1, std::max (2.f, rintf(2.f * ARDOUR_UI::ui_scale)));
+}
bool
ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev)
cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
+ const double dx = rint(max(2., 2. * ARDOUR_UI::ui_scale));
if (_ports.n_total() > 1) {
for (uint32_t i = 0; i < _ports.n_total(); ++i) {
if (i < _ports.n_midi()) {
UINT_RGBA_B_FLT(audio_port_color));
}
const float x = rintf(width * (.2f + .6f * i / (_ports.n_total() - 1.f)));
- cairo_rectangle (cr, x-1, 0, 3, height);
+ cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
cairo_fill(cr);
}
} else if (_ports.n_total() == 1) {
UINT_RGBA_B_FLT(audio_port_color));
}
const float x = rintf(width * .5);
- cairo_rectangle (cr, x-1, 0, 3, height);
+ cairo_rectangle (cr, x-dx * .5, 0, 1+dx, height);
cairo_fill(cr);
cairo_stroke(cr);
}
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
cairo_clip (cr);
- cairo_set_line_width (cr, 1.0);
+ cairo_set_line_width (cr, max (1.f, ARDOUR_UI::ui_scale));
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
Gtk::Allocation a = get_allocation();
const uint32_t sources = _sources.n_total();
const uint32_t sinks = _sinks.n_total();
- /* MIDI */
const uint32_t midi_sources = _sources.n_midi();
const uint32_t midi_sinks = _sinks.n_midi();
+ const uint32_t audio_sources = _sources.n_audio();
+ const uint32_t audio_sinks = _sinks.n_audio();
+ /* MIDI */
cairo_set_source_rgb (cr,
UINT_RGBA_R_FLT(midi_port_color),
UINT_RGBA_G_FLT(midi_port_color),
cairo_move_to (cr, si_x, height);
cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
cairo_stroke (cr);
+ } else if (midi_sources == 0 && midi_sinks == 1) {
+ const double dx = 1 + rint(max(2., 2. * ARDOUR_UI::ui_scale));
+ // draw "T"
+ // TODO connect back to track-input of last midi-out if any, otherwise draw "X"
+ const float si_x = rintf(width * .2f) + .5f;
+ cairo_move_to (cr, si_x, height);
+ cairo_line_to (cr, si_x, height * .66);
+ cairo_move_to (cr, si_x - dx, height * .66);
+ cairo_line_to (cr, si_x + dx, height * .66);
+ cairo_stroke (cr);
+#ifndef NDEBUG
+ } else if (midi_sources != 0 && midi_sinks != 0) {
+ PBD::warning << string_compose("Programming error: midi routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
+ audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
+#endif
}
/* AUDIO */
- const uint32_t audio_sources = _sources.n_audio();
- const uint32_t audio_sinks = _sinks.n_audio();
cairo_set_source_rgb (cr,
UINT_RGBA_R_FLT(audio_port_color),
UINT_RGBA_G_FLT(audio_port_color),
cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
cairo_stroke (cr);
}
- } else if (audio_sources > 1) {
+ } else if (audio_sources > 1 && sinks > 1) {
for (uint32_t i = 0 ; i < audio_sources; ++i) {
const float si_x = rintf(width * (.2f + .6f * (i + midi_sinks) / (sinks - 1.f))) + .5f;
const float si_x0 = rintf(width * (.2f + .6f * (i + midi_sources) / (sources - 1.f))) + .5f;
cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
cairo_stroke (cr);
}
- } else if (audio_sources == 1 && audio_sinks == 1) {
- const float si_x = rintf(width * .5f) + .5f;
+ } else if (audio_sources == 1 && audio_sinks > 0) {
+ float si_x, si_x0;
+ if (sinks == 1) {
+ si_x = rintf(width * .5f) + .5f;
+ } else {
+ si_x = rintf(width * (.2f + .6f * midi_sinks / (sinks - 1.f))) + .5f;
+ }
+ if (sources == 1) {
+ si_x0 = rintf(width * .5f) + .5f;
+ } else {
+ si_x0 = rintf(width * (.2f + .6f * midi_sources / (sources - 1.f))) + .5f;
+ }
cairo_move_to (cr, si_x, height);
- cairo_line_to (cr, si_x, 0);
+ cairo_curve_to (cr, si_x, 0, si_x0, height, si_x0, 0);
cairo_stroke (cr);
+#ifndef NDEBUG
+ } else if (audio_sources != 0 && audio_sinks != 0) {
+ PBD::warning << string_compose("Programming error: audio routing display: A %1 -> %2 | M %3 -> %4 | T %5 -> %6",
+ audio_sources, audio_sinks, midi_sources, midi_sinks, sources, sinks) << endmsg;
+#endif
}
cairo_destroy(cr);
return true;
list<boost::shared_ptr<Processor> > procs;
for (list<ProcessorEntry*>::const_iterator i = children.begin(); i != children.end(); ++i) {
if ((*i)->processor ()) {
+ if (boost::dynamic_pointer_cast<UnknownProcessor> ((*i)->processor())) {
+ continue;
+ }
procs.push_back ((*i)->processor ());
}
}
/* Sensitise actions as approprioate */
- cut_action->set_sensitive (can_cut());
+
+ const bool sensitive = !processor_display.selection().empty() && ! stub_processor_selected ();
+
paste_action->set_sensitive (!_rr_selection.processors.empty());
+ cut_action->set_sensitive (sensitive && can_cut ());
+ copy_action->set_sensitive (sensitive);
+ delete_action->set_sensitive (sensitive || stub_processor_selected ());
- const bool sensitive = !processor_display.selection().empty();
- ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
edit_action->set_sensitive (one_processor_can_be_edited ());
edit_generic_action->set_sensitive (one_processor_can_be_edited ());
edit_action->set_sensitive (pi && pi->plugin()->has_editor ());
/* disallow rename for multiple selections, for plugin inserts and for the fader */
- rename_action->set_sensitive (single_selection && !pi && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ()));
+ rename_action->set_sensitive (single_selection
+ && !pi
+ && !boost::dynamic_pointer_cast<Amp> (single_selection->processor ())
+ && !boost::dynamic_pointer_cast<UnknownProcessor> (single_selection->processor ()));
processor_menu->popup (1, arg);
break;
case ProcessorsPaste:
+ // some processors are not selectable (e.g fader, meter), target is empty.
+ if (targets.empty() && _placement >= 0) {
+ assert (_route);
+ boost::shared_ptr<Processor> proc = _route->before_processor_for_index (_placement);
+ if (proc) {
+ targets.push_back (proc);
+ }
+ }
if (targets.empty()) {
paste_processors ();
} else {
boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
boost::shared_ptr<PortInsert> ext = boost::dynamic_pointer_cast<PortInsert> (processor);
+ boost::shared_ptr<UnknownProcessor> stub = boost::dynamic_pointer_cast<UnknownProcessor> (processor);
//faders and meters are not deletable, copy/paste-able, so they shouldn't be selectable
- if (!send && !plugin_insert && !ext)
+ if (!send && !plugin_insert && !ext && !stub)
e->set_selectable(false);
bool mark_send_visible = false;
bool
ProcessorBox::can_cut () const
{
- vector<boost::shared_ptr<Processor> > sel;
+ vector<boost::shared_ptr<Processor> > sel;
- get_selected_processors (sel);
+ get_selected_processors (sel);
- /* cut_processors () does not cut inserts */
+ /* cut_processors () does not cut inserts */
- for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
+ for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0 ||
(boost::dynamic_pointer_cast<Send>((*i)) != 0) ||
(boost::dynamic_pointer_cast<Return>((*i)) != 0)) {
- return true;
- }
- }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool
+ProcessorBox::stub_processor_selected () const
+{
+ vector<boost::shared_ptr<Processor> > sel;
+
+ get_selected_processors (sel);
- return false;
+ for (vector<boost::shared_ptr<Processor> >::const_iterator i = sel.begin (); i != sel.end (); ++i) {
+ if (boost::dynamic_pointer_cast<UnknownProcessor>((*i)) != 0) {
+ return true;
+ }
+ }
+
+ return false;
}
void
/* XXX its a bit limiting to assume that everything else
is a plugin.
*/
-
p.reset (new PluginInsert (*_session));
- p->set_state (**niter, Stateful::current_state_version);
+ PBD::ID id = p->id();
+ p->set_state (**niter, Stateful::current_state_version);
+ boost::dynamic_pointer_cast<PluginInsert>(p)->update_id (id);
}
copies.push_back (p);
/* standard editing stuff */
cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
sigc::ptr_fun (ProcessorBox::rb_cut));
- ActionManager::plugin_selection_sensitive_actions.push_back(cut_action);
- act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
+ copy_action = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
sigc::ptr_fun (ProcessorBox::rb_copy));
- ActionManager::plugin_selection_sensitive_actions.push_back(act);
-
- act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
+ delete_action = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
sigc::ptr_fun (ProcessorBox::rb_delete));
- ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
sigc::ptr_fun (ProcessorBox::rb_paste));