2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "ardour/amp.h"
23 #include "ardour/route_group.h"
24 #include "ardour/session_route.h"
25 #include "ardour/dB.h"
26 #include "ardour/utils.h"
29 #include <gtkmm/style.h>
30 #include <gdkmm/color.h>
31 #include <gtkmm2ext/utils.h>
32 #include <gtkmm2ext/fastmeter.h>
33 #include <gtkmm2ext/barcontroller.h>
34 #include <gtkmm2ext/gtk_ui.h>
35 #include "pbd/fastlog.h"
36 #include "pbd/stacktrace.h"
38 #include "ardour_ui.h"
39 #include "gain_meter.h"
40 #include "global_signals.h"
42 #include "gui_thread.h"
44 #include "public_editor.h"
46 #include "meter_patterns.h"
48 #include "ardour/session.h"
49 #include "ardour/route.h"
50 #include "ardour/meter.h"
51 #include "ardour/audio_track.h"
52 #include "ardour/midi_track.h"
56 using namespace ARDOUR;
58 using namespace Gtkmm2ext;
61 using Gtkmm2ext::Keyboard;
62 using namespace ArdourMeter;
64 GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int fader_girth)
65 : gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0.0, 1.0, 0.01, 0.1)
66 , gain_automation_style_button ("")
67 , gain_automation_state_button ("")
68 , _data_type (DataType::AUDIO)
71 using namespace Menu_Helpers;
75 ignore_toggle = false;
77 next_release_selects = false;
81 gain_slider = manage (new HSliderController (&gain_adjustment, fader_length, fader_girth, false));
83 gain_slider = manage (new VSliderController (&gain_adjustment, fader_length, fader_girth, false));
86 level_meter = new LevelMeterHBox(_session);
88 level_meter->ButtonPress.connect_same_thread (_level_meter_connection, boost::bind (&GainMeterBase::level_meter_button_press, this, _1));
89 meter_metric_area.signal_button_press_event().connect (sigc::mem_fun (*this, &GainMeterBase::level_meter_button_press));
90 meter_metric_area.add_events (Gdk::BUTTON_PRESS_MASK);
92 gain_slider->signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_press), false);
93 gain_slider->signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeter::gain_slider_button_release), false);
94 gain_slider->set_name ("GainFader");
96 gain_display.set_name ("MixerStripGainDisplay");
97 set_size_request_to_display_given_text (gain_display, "-80.g", 2, 6); /* note the descender */
98 gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
99 gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
100 gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
102 peak_display.set_name ("MixerStripPeakDisplay");
103 set_size_request_to_display_given_text (peak_display, "-80.g", 2, 6); /* note the descender */
104 max_peak = minus_infinity();
105 peak_display.set_label (_("-inf"));
106 peak_display.unset_flags (Gtk::CAN_FOCUS);
108 gain_automation_style_button.set_name ("mixer strip button");
109 gain_automation_state_button.set_name ("mixer strip button");
111 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
112 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
114 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
115 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
117 gain_automation_state_button.set_size_request(15, 15);
118 gain_automation_style_button.set_size_request(15, 15);
120 gain_astyle_menu.items().push_back (MenuElem (_("Trim")));
121 gain_astyle_menu.items().push_back (MenuElem (_("Abs")));
123 gain_astate_menu.set_name ("ArdourContextMenu");
124 gain_astyle_menu.set_name ("ArdourContextMenu");
126 gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::gain_adjusted));
127 peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeterBase::peak_button_release), false);
128 gain_display.signal_key_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_key_press), false);
130 ResetAllPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_peak_display));
131 ResetRoutePeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_route_peak_display));
132 ResetGroupPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_group_peak_display));
133 RedrawMetrics.connect (sigc::mem_fun(*this, &GainMeterBase::redraw_metrics));
135 UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
136 ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
137 DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
139 // PBD::ScopedConnection _config_connection;
140 // Config->ParameterChanged.connect ( _config_connection, MISSING_INVALIDATOR, boost::bind(&GainMeterBase::set_flat_buttons, this, _1), gui_context() );
144 GainMeterBase::set_flat_buttons ()
146 printf("set_flat_butt\n");
147 // gain_slider->set_flat_buttons( ARDOUR_UI::config()->get_flat_buttons() );
150 GainMeterBase::~GainMeterBase ()
157 GainMeterBase::set_controls (boost::shared_ptr<Route> r,
158 boost::shared_ptr<PeakMeter> pm,
159 boost::shared_ptr<Amp> amp)
161 connections.clear ();
162 model_connections.drop_connections ();
165 level_meter->set_meter (0);
166 gain_slider->set_controllable (boost::shared_ptr<PBD::Controllable>());
177 level_meter->set_meter (pm.get());
178 gain_slider->set_controllable (amp->gain_control());
181 amp->ConfigurationChanged.connect (
182 model_connections, invalidator (*this), boost::bind (&GainMeterBase::setup_gain_adjustment, this), gui_context ()
186 setup_gain_adjustment ();
188 if (!_route || !_route->is_auditioner()) {
190 using namespace Menu_Helpers;
192 gain_astate_menu.items().clear ();
194 gain_astate_menu.items().push_back (MenuElem (S_("Automation|Manual"),
195 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
196 Evoral::Parameter(GainAutomation), (AutoState) ARDOUR::Off)));
197 gain_astate_menu.items().push_back (MenuElem (_("Play"),
198 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
199 Evoral::Parameter(GainAutomation), (AutoState) Play)));
200 gain_astate_menu.items().push_back (MenuElem (_("Write"),
201 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
202 Evoral::Parameter(GainAutomation), (AutoState) Write)));
203 gain_astate_menu.items().push_back (MenuElem (_("Touch"),
204 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
205 Evoral::Parameter(GainAutomation), (AutoState) Touch)));
207 connections.push_back (gain_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
208 connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
210 boost::shared_ptr<AutomationControl> gc = amp->gain_control();
212 gc->alist()->automation_state_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
213 gc->alist()->automation_style_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_style_changed, this), gui_context());
215 gain_automation_state_changed ();
218 amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
222 update_gain_sensitive ();
226 GainMeterBase::setup_gain_adjustment ()
232 if (_previous_amp_output_streams == _amp->output_streams ()) {
236 ignore_toggle = true;
238 if (_amp->output_streams().n_midi() <= _amp->output_streams().n_audio()) {
239 _data_type = DataType::AUDIO;
240 gain_adjustment.set_lower (0.0);
241 gain_adjustment.set_upper (1.0);
242 gain_adjustment.set_step_increment (0.01);
243 gain_adjustment.set_page_increment (0.1);
244 gain_slider->set_default_value (gain_to_slider_position (1));
246 _data_type = DataType::MIDI;
247 gain_adjustment.set_lower (0.0);
248 gain_adjustment.set_upper (2.0);
249 gain_adjustment.set_step_increment (1.0/128.0);
250 gain_adjustment.set_page_increment (10.0/128.0);
251 gain_slider->set_default_value (1.0);
254 ignore_toggle = false;
256 effective_gain_display ();
258 _previous_amp_output_streams = _amp->output_streams ();
262 GainMeterBase::hide_all_meters ()
264 level_meter->hide_meters();
268 GainMeter::hide_all_meters ()
270 GainMeterBase::hide_all_meters ();
274 GainMeterBase::setup_meters (int len)
280 //meter_ticks1_area.show();
281 //meter_ticks2_area.show();
282 meter_metric_area.show();
283 if (_route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
288 if (_route && _route->shared_peak_meter()->input_streams().n_total() > 1) {
291 //meter_ticks1_area.hide();
292 //meter_ticks2_area.hide();
293 meter_metric_area.hide();
296 level_meter->setup_meters(len, meter_width);
300 GainMeterBase::set_type (MeterType t)
302 level_meter->set_type(t);
306 GainMeter::setup_meters (int len)
310 hbox.set_homogeneous(true);
313 hbox.set_homogeneous(false);
316 GainMeterBase::setup_meters (len);
320 GainMeter::set_type (MeterType t)
322 GainMeterBase::set_type (t);
326 GainMeterBase::gain_key_press (GdkEventKey* ev)
328 if (key_is_legal_for_numeric_entry (ev->keyval)) {
329 /* drop through to normal handling */
332 /* illegal key for gain entry */
337 GainMeterBase::peak_button_release (GdkEventButton* ev)
339 /* reset peak label */
341 if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
342 ResetAllPeakDisplays ();
343 } else if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
345 ResetGroupPeakDisplays (_route->route_group());
348 ResetRoutePeakDisplays (_route.get());
355 GainMeterBase::reset_peak_display ()
358 level_meter->clear_meters();
359 max_peak = -INFINITY;
360 peak_display.set_label (_("-inf"));
361 peak_display.set_name ("MixerStripPeakDisplay");
365 GainMeterBase::reset_route_peak_display (Route* route)
367 if (_route && _route.get() == route) {
368 reset_peak_display ();
373 GainMeterBase::reset_group_peak_display (RouteGroup* group)
375 if (_route && group == _route->route_group()) {
376 reset_peak_display ();
381 GainMeterBase::popup_meter_menu (GdkEventButton *ev)
383 using namespace Menu_Helpers;
385 if (meter_menu == 0) {
386 meter_menu = new Gtk::Menu;
387 MenuList& items = meter_menu->items();
389 items.push_back (MenuElem ("-inf .. +0dBFS"));
390 items.push_back (MenuElem ("-10dB .. +0dBFS"));
391 items.push_back (MenuElem ("-4 .. +0dBFS"));
392 items.push_back (SeparatorElem());
393 items.push_back (MenuElem ("-inf .. -2dBFS"));
394 items.push_back (MenuElem ("-10dB .. -2dBFS"));
395 items.push_back (MenuElem ("-4 .. -2dBFS"));
398 meter_menu->popup (1, ev->time);
402 GainMeterBase::gain_focused (GdkEventFocus* ev)
405 gain_display.select_region (0, -1);
407 gain_display.select_region (0, 0);
413 GainMeterBase::gain_activated ()
418 // Switch to user's preferred locale so that
419 // if they use different LC_NUMERIC conventions,
420 // we will honor them.
422 PBD::LocaleGuard lg ("");
423 if (sscanf (gain_display.get_text().c_str(), "%f", &f) != 1) {
428 /* clamp to displayable values */
429 if (_data_type == DataType::AUDIO) {
431 _amp->set_gain (dB_to_coefficient(f), this);
433 f = min (fabs (f), 2.0f);
434 _amp->set_gain (f, this);
437 if (gain_display.has_focus()) {
438 Gtk::Widget* w = gain_display.get_toplevel();
440 Gtk::Window* win = dynamic_cast<Gtk::Window*> (w);
442 /* sigh. gtkmm doesn't wrap get_default_widget() */
445 GtkWidget* f = gtk_window_get_default_widget (win->gobj());
447 gtk_widget_grab_focus (f);
456 GainMeterBase::show_gain ()
460 float v = gain_adjustment.get_value();
462 switch (_data_type) {
463 case DataType::AUDIO:
465 strcpy (buf, _("-inf"));
467 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (v, Config->get_max_gain())));
471 snprintf (buf, sizeof (buf), "%.1f", v);
475 gain_display.set_text (buf);
479 GainMeterBase::gain_adjusted ()
483 /* convert from adjustment range (0..1) to gain coefficient */
485 if (_data_type == DataType::AUDIO) {
486 value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
488 value = gain_adjustment.get_value();
491 if (!ignore_toggle) {
492 if (_route && _route->amp() == _amp) {
493 _route->set_gain (value, this);
495 _amp->set_gain (value, this);
503 GainMeterBase::effective_gain_display ()
507 switch (_data_type) {
508 case DataType::AUDIO:
509 value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain());
512 value = _amp->gain ();
516 if (gain_adjustment.get_value() != value) {
517 ignore_toggle = true;
518 gain_adjustment.set_value (value);
519 ignore_toggle = false;
524 GainMeterBase::gain_changed ()
526 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
530 GainMeterBase::set_meter_strip_name (const char * name)
533 meter_metric_area.set_name (name);
534 sprintf(tmp, "Mark%sLeft", name);
535 meter_ticks1_area.set_name (tmp);
536 sprintf(tmp, "Mark%sRight", name);
537 meter_ticks2_area.set_name (tmp);
541 GainMeterBase::set_fader_name (const char * name)
543 gain_slider->set_name (name);
547 GainMeterBase::update_gain_sensitive ()
549 bool x = !(_amp->gain_control()->alist()->automation_state() & Play);
550 static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (x);
554 next_meter_point (MeterPoint mp)
558 return MeterPreFader;
562 return MeterPostFader;
583 GainMeterBase::meter_press(GdkEventButton* ev)
585 wait_for_release = false;
591 if (!ignore_toggle) {
593 if (Keyboard::is_context_menu_event (ev)) {
595 // no menu at this time.
599 if (Keyboard::is_button2_event(ev)) {
601 // Primary-button2 click is the midi binding click
602 // button2-click is "momentary"
604 if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) {
605 wait_for_release = true;
606 old_meter_point = _route->meter_point ();
610 if (_route && (ev->button == 1 || Keyboard::is_button2_event (ev))) {
612 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
614 /* Primary+Tertiary-click applies change to all routes */
616 _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
619 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
621 /* Primary-click: solo mix group.
622 NOTE: Primary-button2 is MIDI learn.
625 if (ev->button == 1) {
626 set_route_group_meter_point (*_route, next_meter_point (_route->meter_point()));
631 /* click: change just this route */
635 _route->set_meter_point (next_meter_point (_route->meter_point()));
646 GainMeterBase::meter_release(GdkEventButton*)
648 if (!ignore_toggle) {
649 if (wait_for_release) {
650 wait_for_release = false;
653 set_meter_point (*_route, old_meter_point);
662 GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
664 route.set_meter_point (mp);
668 GainMeterBase::set_route_group_meter_point (Route& route, MeterPoint mp)
670 RouteGroup* route_group;
672 if ((route_group = route.route_group ()) != 0) {
673 route_group->foreach_route (boost::bind (&Route::set_meter_point, _1, mp, false));
675 route.set_meter_point (mp);
680 GainMeterBase::meter_point_clicked ()
688 GainMeterBase::gain_slider_button_press (GdkEventButton* ev)
691 case GDK_BUTTON_PRESS:
692 _amp->gain_control()->start_touch (_amp->session().transport_frame());
702 GainMeterBase::gain_slider_button_release (GdkEventButton*)
704 _amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
709 GainMeterBase::gain_automation_state_button_event (GdkEventButton *ev)
711 if (ev->type == GDK_BUTTON_RELEASE) {
715 switch (ev->button) {
717 gain_astate_menu.popup (1, ev->time);
727 GainMeterBase::gain_automation_style_button_event (GdkEventButton *ev)
729 if (ev->type == GDK_BUTTON_RELEASE) {
733 switch (ev->button) {
735 gain_astyle_menu.popup (1, ev->time);
744 GainMeterBase::astate_string (AutoState state)
746 return _astate_string (state, false);
750 GainMeterBase::short_astate_string (AutoState state)
752 return _astate_string (state, true);
756 GainMeterBase::_astate_string (AutoState state, bool shrt)
762 sstr = (shrt ? "M" : _("M"));
765 sstr = (shrt ? "P" : _("P"));
768 sstr = (shrt ? "T" : _("T"));
771 sstr = (shrt ? "W" : _("W"));
779 GainMeterBase::astyle_string (AutoStyle style)
781 return _astyle_string (style, false);
785 GainMeterBase::short_astyle_string (AutoStyle style)
787 return _astyle_string (style, true);
791 GainMeterBase::_astyle_string (AutoStyle style, bool shrt)
796 /* XXX it might different in different languages */
798 return (shrt ? _("Abs") : _("Abs"));
803 GainMeterBase::gain_automation_style_changed ()
807 gain_automation_style_button.set_text (astyle_string(_amp->gain_control()->alist()->automation_style()));
810 gain_automation_style_button.set_text (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
816 GainMeterBase::gain_automation_state_changed ()
818 ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed)
824 gain_automation_state_button.set_text (astate_string(_amp->gain_control()->alist()->automation_state()));
827 gain_automation_state_button.set_text (short_astate_string(_amp->gain_control()->alist()->automation_state()));
831 x = (_amp->gain_control()->alist()->automation_state() != ARDOUR::Off);
833 if (gain_automation_state_button.get_active() != x) {
834 ignore_toggle = true;
835 gain_automation_state_button.set_active (x);
836 ignore_toggle = false;
839 update_gain_sensitive ();
841 /* start watching automation so that things move */
843 gain_watching.disconnect();
846 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
851 GainMeterBase::update_meters()
854 float mpeak = level_meter->update_meters();
856 if (mpeak > max_peak) {
858 if (mpeak <= -200.0f) {
859 peak_display.set_label (_("-inf"));
861 snprintf (buf, sizeof(buf), "%.1f", mpeak);
862 peak_display.set_label (buf);
865 if (mpeak >= Config->get_meter_peak()) {
866 peak_display.set_name ("MixerStripPeakDisplayPeak");
870 void GainMeterBase::color_handler(bool /*dpi*/)
876 GainMeterBase::set_width (Width w, int len)
880 if (_width == Wide && _route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
883 level_meter->setup_meters(len, meter_width);
888 GainMeterBase::on_theme_changed()
893 GainMeterBase::redraw_metrics()
895 meter_metric_area.queue_draw ();
896 meter_ticks1_area.queue_draw ();
897 meter_ticks2_area.queue_draw ();
900 GainMeter::GainMeter (Session* s, int fader_length)
901 : GainMeterBase (s, false, fader_length, 24)
902 , gain_display_box(true, 0)
905 if (gain_display.get_parent()) {
906 gain_display.get_parent()->remove (gain_display);
908 gain_display_box.pack_start (gain_display, true, true);
910 meter_metric_area.set_name ("AudioTrackMetrics");
911 meter_metric_area.set_size_request(24, -1);
913 gain_automation_style_button.set_name ("mixer strip button");
914 gain_automation_state_button.set_name ("mixer strip button");
916 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
917 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
919 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
920 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
922 gain_automation_state_button.set_size_request(15, 15);
923 gain_automation_style_button.set_size_request(15, 15);
925 fader_vbox = manage (new Gtk::VBox());
926 fader_vbox->set_spacing (0);
927 fader_vbox->pack_start (*gain_slider, true, true);
929 fader_alignment.set (0.5, 0.5, 0.0, 1.0);
930 fader_alignment.add (*fader_vbox);
932 hbox.pack_start (fader_alignment, true, true);
936 pack_start (gain_display_box, Gtk::PACK_SHRINK);
937 pack_start (hbox, Gtk::PACK_SHRINK);
939 meter_alignment.set (0.5, 0.5, 0.0, 1.0);
940 meter_alignment.add (*level_meter);
942 meter_metric_area.signal_expose_event().connect (
943 sigc::mem_fun(*this, &GainMeter::meter_metrics_expose));
945 meter_ticks1_area.set_size_request(3,-1);
946 meter_ticks2_area.set_size_request(3,-1);
948 meter_ticks1_area.signal_expose_event().connect (
949 sigc::mem_fun(*this, &GainMeter::meter_ticks1_expose));
950 meter_ticks2_area.signal_expose_event().connect (
951 sigc::mem_fun(*this, &GainMeter::meter_ticks2_expose));
953 meter_hbox.pack_start (meter_ticks1_area, false, false);
954 meter_hbox.pack_start (meter_alignment, false, false);
955 meter_hbox.pack_start (meter_ticks2_area, false, false);
956 meter_hbox.pack_start (meter_metric_area, false, false);
959 GainMeter::~GainMeter () { }
962 GainMeter::set_controls (boost::shared_ptr<Route> r,
963 boost::shared_ptr<PeakMeter> meter,
964 boost::shared_ptr<Amp> amp)
966 if (meter_hbox.get_parent()) {
967 hbox.remove (meter_hbox);
970 // if (gain_automation_state_button.get_parent()) {
971 // fader_vbox->remove (gain_automation_state_button);
974 GainMeterBase::set_controls (r, meter, amp);
977 _meter->ConfigurationChanged.connect (
978 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
980 _meter->TypeChanged.connect (
981 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_type_changed, this, _1), gui_context()
984 meter_configuration_changed (_meter->input_streams ());
989 _route->active_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::route_active_changed, this), gui_context ());
993 if we have a non-hidden route (ie. we're not the click or the auditioner),
994 pack some route-dependent stuff.
997 hbox.pack_start (meter_hbox, true, true);
999 // if (r && !r->is_auditioner()) {
1000 // fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
1008 GainMeter::get_gm_width ()
1010 Gtk::Requisition sz;
1012 meter_metric_area.size_request (sz);
1014 level_meter->size_request (sz);
1017 fader_alignment.size_request (sz);
1019 return max(sz.width * 2, min_w * 2) + 6;
1021 return sz.width + min_w + 6;
1026 GainMeter::meter_metrics_expose (GdkEventExpose *ev)
1029 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1030 return meter_expose_metrics(ev, MeterPeak, _types, &meter_metric_area);
1032 return meter_expose_metrics(ev, _route->meter_type(), _types, &meter_metric_area);
1036 GainMeter::meter_ticks1_expose (GdkEventExpose *ev)
1039 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1040 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks1_area);
1042 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks1_area);
1046 GainMeter::meter_ticks2_expose (GdkEventExpose *ev)
1049 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1050 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks2_area);
1052 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks2_area);
1055 boost::shared_ptr<PBD::Controllable>
1056 GainMeterBase::get_controllable()
1059 return _amp->gain_control();
1061 return boost::shared_ptr<PBD::Controllable>();
1066 GainMeterBase::level_meter_button_press (GdkEventButton* ev)
1068 return LevelMeterButtonPress (ev); /* EMIT SIGNAL */
1072 GainMeter::meter_configuration_changed (ChanCount c)
1077 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
1078 if (c.get (*i) > 0) {
1079 _types.push_back (*i);
1085 && boost::dynamic_pointer_cast<AudioTrack>(_route) == 0
1086 && boost::dynamic_pointer_cast<MidiTrack>(_route) == 0
1088 if (_route->active()) {
1089 set_meter_strip_name ("AudioBusMetrics");
1091 set_meter_strip_name ("AudioBusMetricsInactive");
1095 (type == (1 << DataType::MIDI))
1096 || (_route && boost::dynamic_pointer_cast<MidiTrack>(_route))
1098 if (!_route || _route->active()) {
1099 set_meter_strip_name ("MidiTrackMetrics");
1101 set_meter_strip_name ("MidiTrackMetricsInactive");
1104 else if (type == (1 << DataType::AUDIO)) {
1105 if (!_route || _route->active()) {
1106 set_meter_strip_name ("AudioTrackMetrics");
1108 set_meter_strip_name ("AudioTrackMetricsInactive");
1111 if (!_route || _route->active()) {
1112 set_meter_strip_name ("AudioMidiTrackMetrics");
1114 set_meter_strip_name ("AudioMidiTrackMetricsInactive");
1119 meter_clear_pattern_cache(4);
1123 GainMeter::route_active_changed ()
1126 meter_configuration_changed (_meter->input_streams ());
1131 GainMeter::meter_type_changed (MeterType t)
1133 _route->set_meter_type(t);