Add a meter to Foldback bus

Spaces got replaced by tabs as well.
This commit is contained in:
Len Ovens 2020-05-07 17:12:36 -07:00
parent 21bb10238e
commit 8e1e271eba
3 changed files with 117 additions and 49 deletions

View file

@ -1,19 +1,19 @@
/* /*
Copyright (C) 2018-2019 Len Ovens Copyright (C) 2018-2019 Len Ovens
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "ardour/audioengine.h" #include "ardour/audioengine.h"
@ -26,11 +26,14 @@
#include "ardour/session.h" #include "ardour/session.h"
#include "ardour/user_bundle.h" #include "ardour/user_bundle.h"
#include "ardour/value_as_string.h" #include "ardour/value_as_string.h"
#include "ardour/meter.h"
#include "ardour/logmeter.h"
#include "gtkmm2ext/gtk_ui.h" #include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/menu_elems.h" #include "gtkmm2ext/menu_elems.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "gtkmm2ext/doi.h" #include "gtkmm2ext/doi.h"
#include "pbd/fastlog.h"
#include "widgets/tooltips.h" #include "widgets/tooltips.h"
@ -298,11 +301,13 @@ FoldbackStrip::FoldbackStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Rou
, _mixer_owned (true) , _mixer_owned (true)
, _showing_sends (false) , _showing_sends (false)
, _width (80) , _width (80)
, _peak_meter (0)
, _pr_selection () , _pr_selection ()
, panners (sess) , panners (sess)
, _plugin_insert_cnt (0) , _plugin_insert_cnt (0)
, _comment_button (_("Comments")) , _comment_button (_("Comments"))
, fb_level_control (0) , fb_level_control (0)
, _meter (0)
{ {
_session = sess; _session = sess;
init (); init ();
@ -365,6 +370,27 @@ FoldbackStrip::init ()
insert_box->set_width (Wide); insert_box->set_width (Wide);
insert_box->set_size_request (PX_SCALE(_width + 34), PX_SCALE(160)); insert_box->set_size_request (PX_SCALE(_width + 34), PX_SCALE(160));
_meter = new FastMeter ((uint32_t) floor (UIConfiguration::instance().get_meter_hold()),
8, FastMeter::Horizontal, PX_SCALE(100),
UIConfiguration::instance().color ("meter color0"),
UIConfiguration::instance().color ("meter color1"),
UIConfiguration::instance().color ("meter color2"),
UIConfiguration::instance().color ("meter color3"),
UIConfiguration::instance().color ("meter color4"),
UIConfiguration::instance().color ("meter color5"),
UIConfiguration::instance().color ("meter color6"),
UIConfiguration::instance().color ("meter color7"),
UIConfiguration::instance().color ("meter color8"),
UIConfiguration::instance().color ("meter color9"),
UIConfiguration::instance().color ("meter background bottom"),
UIConfiguration::instance().color ("meter background top"),
0x991122ff, 0x551111ff,
(115.0 * log_meter0dB(-15)),
89.125,
106.375,
115.0,
(UIConfiguration::instance().get_meter_style_led() ? 3 : 1));
fb_level_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent); fb_level_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent);
fb_level_control->set_size_request (PX_SCALE(50), PX_SCALE(50)); fb_level_control->set_size_request (PX_SCALE(50), PX_SCALE(50));
fb_level_control->set_tooltip_prefix (_("Level: ")); fb_level_control->set_tooltip_prefix (_("Level: "));
@ -421,6 +447,7 @@ FoldbackStrip::init ()
global_vpacker.pack_end (_comment_button, Gtk::PACK_SHRINK); global_vpacker.pack_end (_comment_button, Gtk::PACK_SHRINK);
global_vpacker.pack_end (output_button, Gtk::PACK_SHRINK); global_vpacker.pack_end (output_button, Gtk::PACK_SHRINK);
global_vpacker.pack_end (master_box, Gtk::PACK_SHRINK); global_vpacker.pack_end (master_box, Gtk::PACK_SHRINK);
global_vpacker.pack_end (*_meter, false, false);
global_vpacker.pack_end (*insert_box, Gtk::PACK_SHRINK); global_vpacker.pack_end (*insert_box, Gtk::PACK_SHRINK);
global_vpacker.pack_end (panners, Gtk::PACK_SHRINK); global_vpacker.pack_end (panners, Gtk::PACK_SHRINK);
@ -452,10 +479,10 @@ FoldbackStrip::init ()
_comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor)); _comment_button.signal_clicked.connect (sigc::mem_fun (*this, &RouteUI::toggle_comment_editor));
add_events (Gdk::BUTTON_RELEASE_MASK| add_events (Gdk::BUTTON_RELEASE_MASK|
Gdk::ENTER_NOTIFY_MASK| Gdk::ENTER_NOTIFY_MASK|
Gdk::LEAVE_NOTIFY_MASK| Gdk::LEAVE_NOTIFY_MASK|
Gdk::KEY_PRESS_MASK| Gdk::KEY_PRESS_MASK|
Gdk::KEY_RELEASE_MASK); Gdk::KEY_RELEASE_MASK);
set_flags (get_flags() | Gtk::CAN_FOCUS); set_flags (get_flags() | Gtk::CAN_FOCUS);
@ -543,6 +570,7 @@ FoldbackStrip::set_route (boost::shared_ptr<Route> rt)
return; return;
} }
if (_route) { if (_route) {
// just in case
_route->solo_control()->set_value (0.0, Controllable::NoGroup); _route->solo_control()->set_value (0.0, Controllable::NoGroup);
} }
@ -562,6 +590,12 @@ FoldbackStrip::set_route (boost::shared_ptr<Route> rt)
_route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::connect_to_pan, this), gui_context()); _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::connect_to_pan, this), gui_context());
} }
// set up metering
_peak_meter = _route->shared_peak_meter().get();
_route->set_meter_point (MeterPostFader);
// _route->set_meter_point (MeterPreFader);
_route->set_meter_type (MeterPeak0dB);
_route->output()->changed.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::update_output_display, this), gui_context()); _route->output()->changed.connect (*this, invalidator (*this), boost::bind (&FoldbackStrip::update_output_display, this), gui_context());
_route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::io_changed_proxy, this), gui_context ()); _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&FoldbackStrip::io_changed_proxy, this), gui_context ());
@ -589,6 +623,7 @@ FoldbackStrip::set_route (boost::shared_ptr<Route> rt)
send_scroller.show (); send_scroller.show ();
_show_sends_button.show(); _show_sends_button.show();
insert_box->show (); insert_box->show ();
_meter->show ();
master_box.show(); master_box.show();
output_button.show(); output_button.show();
_comment_button.show(); _comment_button.show();
@ -743,7 +778,7 @@ FoldbackStrip::output_press (GdkEventButton *ev)
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration))); citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));
Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "", Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "",
1, ev->time); 1, ev->time);
break; break;
} }
@ -766,7 +801,7 @@ FoldbackStrip::bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle> c)
void void
FoldbackStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const& /*current*/, FoldbackStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const& /*current*/,
DataType type) DataType type)
{ {
using namespace Menu_Helpers; using namespace Menu_Helpers;
@ -895,16 +930,16 @@ FoldbackStrip::update_io_button ()
string arrow = Gtkmm2ext::markup_escape_text(" -> "); string arrow = Gtkmm2ext::markup_escape_text(" -> ");
vector<string> port_connections; vector<string> port_connections;
for (PortSet::iterator port = io->ports().begin(); for (PortSet::iterator port = io->ports().begin();
port != io->ports().end(); port != io->ports().end();
++port) { ++port) {
port_connections.clear(); port_connections.clear();
port->get_connections(port_connections); port->get_connections(port_connections);
uint32_t port_connection_count = 0; uint32_t port_connection_count = 0;
for (vector<string>::iterator i = port_connections.begin(); for (vector<string>::iterator i = port_connections.begin();
i != port_connections.end(); i != port_connections.end();
++i) { ++i) {
++port_connection_count; ++port_connection_count;
if (port_connection_count == 1) { if (port_connection_count == 1) {
@ -939,12 +974,12 @@ FoldbackStrip::update_io_button ()
if (!have_label) { if (!have_label) {
boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes (); boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
for (ARDOUR::RouteList::const_iterator route = routes->begin(); for (ARDOUR::RouteList::const_iterator route = routes->begin();
route != routes->end(); route != routes->end();
++route) { ++route) {
boost::shared_ptr<IO> dest_io = (*route)->output(); boost::shared_ptr<IO> dest_io = (*route)->output();
if (io->bundle()->connected_to(dest_io->bundle(), if (io->bundle()->connected_to(dest_io->bundle(),
_session->engine(), _session->engine(),
dt, true)) { dt, true)) {
label << Gtkmm2ext::markup_escape_text ((*route)->name()); label << Gtkmm2ext::markup_escape_text ((*route)->name());
have_label = true; have_label = true;
break; break;
@ -956,12 +991,12 @@ FoldbackStrip::update_io_button ()
if (!have_label) { if (!have_label) {
boost::shared_ptr<ARDOUR::BundleList> bundles = _session->bundles (); boost::shared_ptr<ARDOUR::BundleList> bundles = _session->bundles ();
for (ARDOUR::BundleList::iterator bundle = bundles->begin(); for (ARDOUR::BundleList::iterator bundle = bundles->begin();
bundle != bundles->end(); bundle != bundles->end();
++bundle) { ++bundle) {
if (boost::dynamic_pointer_cast<UserBundle> (*bundle) == 0) if (boost::dynamic_pointer_cast<UserBundle> (*bundle) == 0)
continue; continue;
if (io->bundle()->connected_to(*bundle, _session->engine(), if (io->bundle()->connected_to(*bundle, _session->engine(),
dt, true)) { dt, true)) {
label << Gtkmm2ext::markup_escape_text ((*bundle)->name()); label << Gtkmm2ext::markup_escape_text ((*bundle)->name());
have_label = true; have_label = true;
break; break;
@ -978,12 +1013,12 @@ FoldbackStrip::update_io_button ()
_session->engine().get_physical_outputs(dt, phys); _session->engine().get_physical_outputs(dt, phys);
playorcapture = "playback_"; playorcapture = "playback_";
for (PortSet::iterator port = io->ports().begin(dt); for (PortSet::iterator port = io->ports().begin(dt);
port != io->ports().end(dt); port != io->ports().end(dt);
++port) { ++port) {
string pn = ""; string pn = "";
for (vector<string>::iterator s = phys.begin(); for (vector<string>::iterator s = phys.begin();
s != phys.end(); s != phys.end();
++s) { ++s) {
if (!port->connected_to(*s)) if (!port->connected_to(*s))
continue; continue;
pn = AudioEngine::instance()->get_pretty_name_by_name(*s); pn = AudioEngine::instance()->get_pretty_name_by_name(*s);
@ -1016,8 +1051,8 @@ FoldbackStrip::update_io_button ()
string maybe_client = ""; string maybe_client = "";
vector<string> connections; vector<string> connections;
for (PortSet::iterator port = io->ports().begin(dt); for (PortSet::iterator port = io->ports().begin(dt);
port != io->ports().end(dt); port != io->ports().end(dt);
++port) { ++port) {
port_connections.clear(); port_connections.clear();
port->get_connections(port_connections); port->get_connections(port_connections);
string connection = port_connections.front(); string connection = port_connections.front();
@ -1206,7 +1241,7 @@ FoldbackStrip::name_button_button_press (GdkEventButton* ev)
Menu* menu = build_route_select_menu (); Menu* menu = build_route_select_menu ();
Gtkmm2ext::anchored_menu_popup(menu, &name_button, "", Gtkmm2ext::anchored_menu_popup(menu, &name_button, "",
1, ev->time); 1, ev->time);
} }
return true; return true;
} else if (ev->button == 3) { } else if (ev->button == 3) {
@ -1316,6 +1351,29 @@ FoldbackStrip::show_sends_clicked ()
} }
} }
void
FoldbackStrip::fast_update ()
{
/*
* As this is the output level to a DAC, peak level is what is important
* So, much like the mackie control, we just want the highest peak from
* all channels in the route.
*/
float meter_level = -199.0;
uint32_t mn = _peak_meter->input_streams().n_audio();
for (uint32_t n = 0; n != mn; ++n) {
const float peak = _peak_meter->meter_level(n, MeterPeak0dB);
if (peak > meter_level) {
meter_level = peak;
}
}
_meter->set (log_meter0dB (meter_level));
}
void void
FoldbackStrip::send_blink (bool onoff) FoldbackStrip::send_blink (bool onoff)
{ {

View file

@ -1,19 +1,19 @@
/* /*
Copyright (C) 2018-2019 Len Ovens Copyright (C) 2018-2019 Len Ovens
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef __ardour_foldback_strip__ #ifndef __ardour_foldback_strip__
@ -40,11 +40,13 @@
#include "ardour/types.h" #include "ardour/types.h"
#include "ardour/ardour.h" #include "ardour/ardour.h"
#include "ardour/processor.h" #include "ardour/processor.h"
#include "ardour/meter.h"
#include "pbd/fastlog.h" #include "pbd/fastlog.h"
#include "widgets/ardour_button.h" #include "widgets/ardour_button.h"
#include "widgets/ardour_knob.h" #include "widgets/ardour_knob.h"
#include "widgets/fastmeter.h"
#include "route_ui.h" #include "route_ui.h"
#include "panner_ui.h" #include "panner_ui.h"
@ -60,6 +62,7 @@ namespace ARDOUR {
class PortInsert; class PortInsert;
class Bundle; class Bundle;
class Plugin; class Plugin;
class PeakMeter;
} }
namespace Gtk { namespace Gtk {
class Window; class Window;
@ -126,6 +129,8 @@ public:
void set_embedded (bool); void set_embedded (bool);
void fast_update ();
void set_route (boost::shared_ptr<ARDOUR::Route>); void set_route (boost::shared_ptr<ARDOUR::Route>);
void set_button_names (); void set_button_names ();
void revert_to_default_display (); void revert_to_default_display ();
@ -176,6 +181,7 @@ private:
ARDOUR::Session* _session; ARDOUR::Session* _session;
bool _showing_sends; bool _showing_sends;
uint32_t _width; uint32_t _width;
ARDOUR::PeakMeter* _peak_meter;
Gtk::EventBox spacer; Gtk::EventBox spacer;
Gtk::VBox send_display; Gtk::VBox send_display;
@ -204,6 +210,7 @@ private:
ArdourWidgets::ArdourButton _hide_button; ArdourWidgets::ArdourButton _hide_button;
ArdourWidgets::ArdourButton _comment_button; ArdourWidgets::ArdourButton _comment_button;
ArdourWidgets::ArdourKnob* fb_level_control; ArdourWidgets::ArdourKnob* fb_level_control;
ArdourWidgets::FastMeter* _meter;
void setup_comment_button (); void setup_comment_button ();
void hide_clicked(); void hide_clicked();
@ -214,7 +221,7 @@ private:
Gtk::Menu output_menu; Gtk::Menu output_menu;
std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles; std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &, void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &,
ARDOUR::DataType type = ARDOUR::DataType::NIL); ARDOUR::DataType type = ARDOUR::DataType::NIL);
void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>); void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);

View file

@ -1388,6 +1388,9 @@ Mixer_UI::fast_update_strips ()
for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) { for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
(*i)->fast_update (); (*i)->fast_update ();
} }
if (foldback_strip) {
foldback_strip->fast_update ();
}
} }
} }