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/gtk_ui.h>
34 #include "pbd/fastlog.h"
35 #include "pbd/stacktrace.h"
37 #include "ardour_ui.h"
38 #include "gain_meter.h"
39 #include "global_signals.h"
41 #include "gui_thread.h"
43 #include "public_editor.h"
45 #include "meter_patterns.h"
47 #include "ardour/session.h"
48 #include "ardour/route.h"
49 #include "ardour/meter.h"
50 #include "ardour/audio_track.h"
51 #include "ardour/midi_track.h"
55 using namespace ARDOUR;
56 using namespace ARDOUR_UI_UTILS;
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));
83 gain_slider = manage (new VSliderController (&gain_adjustment, fader_length, fader_girth));
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->set_tweaks (PixFader::Tweaks(PixFader::NoButtonForward | PixFader::NoVerticalScroll));
93 gain_slider->StartGesture.connect (sigc::mem_fun (*this, &GainMeter::amp_start_touch));
94 gain_slider->StopGesture.connect (sigc::mem_fun (*this, &GainMeter::amp_stop_touch));
95 gain_slider->set_name ("GainFader");
97 gain_display.set_name ("MixerStripGainDisplay");
98 set_size_request_to_display_given_text (gain_display, "-80.g", 2, 6); /* note the descender */
99 gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
100 gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
101 gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
102 gain_display.set_alignment(0.5);
104 peak_display.set_name ("MixerStripPeakDisplay");
105 set_size_request_to_display_given_text (peak_display, "-80.g", 2, 6); /* note the descender */
106 max_peak = minus_infinity();
107 peak_display.set_text (_("-inf"));
108 peak_display.unset_flags (Gtk::CAN_FOCUS);
109 peak_display.set_alignment(0.5);
111 gain_automation_style_button.set_name ("mixer strip button");
112 gain_automation_state_button.set_name ("mixer strip button");
114 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
115 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
117 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
118 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
120 gain_automation_state_button.set_size_request(15, 15);
121 gain_automation_style_button.set_size_request(15, 15);
123 gain_astyle_menu.items().push_back (MenuElem (_("Trim")));
124 gain_astyle_menu.items().push_back (MenuElem (_("Abs")));
126 gain_astate_menu.set_name ("ArdourContextMenu");
127 gain_astyle_menu.set_name ("ArdourContextMenu");
129 gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::gain_adjusted));
130 peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeterBase::peak_button_release), false);
131 gain_display.signal_key_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_key_press), false);
133 ResetAllPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_peak_display));
134 ResetRoutePeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_route_peak_display));
135 ResetGroupPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_group_peak_display));
136 RedrawMetrics.connect (sigc::mem_fun(*this, &GainMeterBase::redraw_metrics));
138 UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
139 ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
140 DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
143 GainMeterBase::~GainMeterBase ()
150 GainMeterBase::set_controls (boost::shared_ptr<Route> r,
151 boost::shared_ptr<PeakMeter> pm,
152 boost::shared_ptr<Amp> amp)
154 connections.clear ();
155 model_connections.drop_connections ();
158 level_meter->set_meter (0);
159 gain_slider->set_controllable (boost::shared_ptr<PBD::Controllable>());
170 level_meter->set_meter (pm.get());
171 gain_slider->set_controllable (amp->gain_control());
174 amp->ConfigurationChanged.connect (
175 model_connections, invalidator (*this), boost::bind (&GainMeterBase::setup_gain_adjustment, this), gui_context ()
179 setup_gain_adjustment ();
181 if (!_route || !_route->is_auditioner()) {
183 using namespace Menu_Helpers;
185 gain_astate_menu.items().clear ();
187 gain_astate_menu.items().push_back (MenuElem (S_("Automation|Manual"),
188 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
189 Evoral::Parameter(GainAutomation), (AutoState) ARDOUR::Off)));
190 gain_astate_menu.items().push_back (MenuElem (_("Play"),
191 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
192 Evoral::Parameter(GainAutomation), (AutoState) Play)));
193 gain_astate_menu.items().push_back (MenuElem (_("Write"),
194 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
195 Evoral::Parameter(GainAutomation), (AutoState) Write)));
196 gain_astate_menu.items().push_back (MenuElem (_("Touch"),
197 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
198 Evoral::Parameter(GainAutomation), (AutoState) Touch)));
200 connections.push_back (gain_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
201 connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
203 boost::shared_ptr<AutomationControl> gc = amp->gain_control();
205 gc->alist()->automation_state_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
206 gc->alist()->automation_style_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_style_changed, this), gui_context());
208 gain_automation_state_changed ();
211 amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
215 update_gain_sensitive ();
219 GainMeterBase::setup_gain_adjustment ()
225 if (_previous_amp_output_streams == _amp->output_streams ()) {
229 ignore_toggle = true;
231 if (_amp->output_streams().n_midi() <= _amp->output_streams().n_audio()) {
232 _data_type = DataType::AUDIO;
233 gain_adjustment.set_lower (0.0);
234 gain_adjustment.set_upper (1.0);
235 gain_adjustment.set_step_increment (0.01);
236 gain_adjustment.set_page_increment (0.1);
237 gain_slider->set_default_value (gain_to_slider_position (1));
239 _data_type = DataType::MIDI;
240 gain_adjustment.set_lower (0.0);
241 gain_adjustment.set_upper (2.0);
242 gain_adjustment.set_step_increment (1.0/128.0);
243 gain_adjustment.set_page_increment (10.0/128.0);
244 gain_slider->set_default_value (1.0);
247 ignore_toggle = false;
249 effective_gain_display ();
251 _previous_amp_output_streams = _amp->output_streams ();
255 GainMeterBase::hide_all_meters ()
257 level_meter->hide_meters();
261 GainMeter::hide_all_meters ()
263 GainMeterBase::hide_all_meters ();
267 GainMeterBase::setup_meters (int len)
270 uint32_t meter_channels = 0;
272 meter_channels = _meter->input_streams().n_total();
274 meter_channels = _route->shared_peak_meter()->input_streams().n_total();
279 //meter_ticks1_area.show();
280 //meter_ticks2_area.show();
281 meter_metric_area.show();
282 if (meter_channels == 1) {
287 if (meter_channels > 1) {
290 //meter_ticks1_area.hide();
291 //meter_ticks2_area.hide();
292 meter_metric_area.hide();
295 level_meter->setup_meters(len, meter_width);
299 GainMeterBase::set_type (MeterType t)
301 level_meter->set_type(t);
305 GainMeter::setup_meters (int len)
310 uint32_t meter_channels = 0;
312 meter_channels = _meter->input_streams().n_total();
314 meter_channels = _route->shared_peak_meter()->input_streams().n_total();
316 hbox.set_homogeneous(meter_channels < 7 ? true : false);
320 hbox.set_homogeneous(false);
323 GainMeterBase::setup_meters (len);
327 GainMeter::set_type (MeterType t)
329 GainMeterBase::set_type (t);
333 GainMeterBase::gain_key_press (GdkEventKey* ev)
335 if (key_is_legal_for_numeric_entry (ev->keyval)) {
336 /* drop through to normal handling */
339 /* illegal key for gain entry */
344 GainMeterBase::peak_button_release (GdkEventButton* ev)
346 /* reset peak label */
348 if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
349 ResetAllPeakDisplays ();
350 } else if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
352 ResetGroupPeakDisplays (_route->route_group());
355 ResetRoutePeakDisplays (_route.get());
362 GainMeterBase::reset_peak_display ()
365 level_meter->clear_meters();
366 max_peak = -INFINITY;
367 peak_display.set_text (_("-inf"));
368 peak_display.set_name ("MixerStripPeakDisplay");
372 GainMeterBase::reset_route_peak_display (Route* route)
374 if (_route && _route.get() == route) {
375 reset_peak_display ();
380 GainMeterBase::reset_group_peak_display (RouteGroup* group)
382 if (_route && group == _route->route_group()) {
383 reset_peak_display ();
388 GainMeterBase::popup_meter_menu (GdkEventButton *ev)
390 using namespace Menu_Helpers;
392 if (meter_menu == 0) {
393 meter_menu = new Gtk::Menu;
394 MenuList& items = meter_menu->items();
396 items.push_back (MenuElem ("-inf .. +0dBFS"));
397 items.push_back (MenuElem ("-10dB .. +0dBFS"));
398 items.push_back (MenuElem ("-4 .. +0dBFS"));
399 items.push_back (SeparatorElem());
400 items.push_back (MenuElem ("-inf .. -2dBFS"));
401 items.push_back (MenuElem ("-10dB .. -2dBFS"));
402 items.push_back (MenuElem ("-4 .. -2dBFS"));
405 meter_menu->popup (1, ev->time);
409 GainMeterBase::gain_focused (GdkEventFocus* ev)
412 gain_display.select_region (0, -1);
414 gain_display.select_region (0, 0);
420 GainMeterBase::gain_activated ()
425 // Switch to user's preferred locale so that
426 // if they use different LC_NUMERIC conventions,
427 // we will honor them.
429 PBD::LocaleGuard lg ("");
430 if (sscanf (gain_display.get_text().c_str(), "%f", &f) != 1) {
435 /* clamp to displayable values */
436 if (_data_type == DataType::AUDIO) {
438 _amp->set_gain (dB_to_coefficient(f), this);
440 f = min (fabs (f), 2.0f);
441 _amp->set_gain (f, this);
444 if (gain_display.has_focus()) {
445 Gtk::Widget* w = gain_display.get_toplevel();
447 Gtk::Window* win = dynamic_cast<Gtk::Window*> (w);
449 /* sigh. gtkmm doesn't wrap get_default_widget() */
452 GtkWidget* f = gtk_window_get_default_widget (win->gobj());
454 gtk_widget_grab_focus (f);
463 GainMeterBase::show_gain ()
467 float v = gain_adjustment.get_value();
469 switch (_data_type) {
470 case DataType::AUDIO:
472 strcpy (buf, _("-inf"));
474 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (v, Config->get_max_gain())));
478 snprintf (buf, sizeof (buf), "%.1f", v);
482 gain_display.set_text (buf);
486 GainMeterBase::gain_adjusted ()
490 /* convert from adjustment range (0..1) to gain coefficient */
492 if (_data_type == DataType::AUDIO) {
493 value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
495 value = gain_adjustment.get_value();
498 if (!ignore_toggle) {
499 if (_route && _route->amp() == _amp) {
500 _route->set_gain (value, this);
502 _amp->set_gain (value, this);
510 GainMeterBase::effective_gain_display ()
514 switch (_data_type) {
515 case DataType::AUDIO:
516 value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain());
519 value = _amp->gain ();
523 if (gain_adjustment.get_value() != value) {
524 ignore_toggle = true;
525 gain_adjustment.set_value (value);
526 ignore_toggle = false;
531 GainMeterBase::gain_changed ()
533 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
537 GainMeterBase::set_meter_strip_name (const char * name)
540 meter_metric_area.set_name (name);
541 sprintf(tmp, "Mark%sLeft", name);
542 meter_ticks1_area.set_name (tmp);
543 sprintf(tmp, "Mark%sRight", name);
544 meter_ticks2_area.set_name (tmp);
548 GainMeterBase::set_fader_name (const char * name)
550 gain_slider->set_name (name);
554 GainMeterBase::update_gain_sensitive ()
556 bool x = !(_amp->gain_control()->alist()->automation_state() & Play);
557 static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (x);
561 next_meter_point (MeterPoint mp)
565 return MeterPreFader;
569 return MeterPostFader;
590 GainMeterBase::meter_press(GdkEventButton* ev)
592 wait_for_release = false;
598 if (!ignore_toggle) {
600 if (Keyboard::is_context_menu_event (ev)) {
602 // no menu at this time.
606 if (Keyboard::is_button2_event(ev)) {
608 // Primary-button2 click is the midi binding click
609 // button2-click is "momentary"
611 if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) {
612 wait_for_release = true;
613 old_meter_point = _route->meter_point ();
617 if (_route && (ev->button == 1 || Keyboard::is_button2_event (ev))) {
619 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
621 /* Primary+Tertiary-click applies change to all routes */
623 _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
626 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
628 /* Primary-click: solo mix group.
629 NOTE: Primary-button2 is MIDI learn.
632 if (ev->button == 1) {
633 set_route_group_meter_point (*_route, next_meter_point (_route->meter_point()));
638 /* click: change just this route */
642 _route->set_meter_point (next_meter_point (_route->meter_point()));
653 GainMeterBase::meter_release(GdkEventButton*)
655 if (!ignore_toggle) {
656 if (wait_for_release) {
657 wait_for_release = false;
660 set_meter_point (*_route, old_meter_point);
669 GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
671 route.set_meter_point (mp);
675 GainMeterBase::set_route_group_meter_point (Route& route, MeterPoint mp)
677 RouteGroup* route_group;
679 if ((route_group = route.route_group ()) != 0) {
680 route_group->foreach_route (boost::bind (&Route::set_meter_point, _1, mp, false));
682 route.set_meter_point (mp);
687 GainMeterBase::meter_point_clicked ()
695 GainMeterBase::amp_start_touch ()
697 _amp->gain_control()->start_touch (_amp->session().transport_frame());
701 GainMeterBase::amp_stop_touch ()
703 _amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
707 GainMeterBase::gain_automation_state_button_event (GdkEventButton *ev)
709 if (ev->type == GDK_BUTTON_RELEASE) {
713 switch (ev->button) {
715 gain_astate_menu.popup (1, ev->time);
725 GainMeterBase::gain_automation_style_button_event (GdkEventButton *ev)
727 if (ev->type == GDK_BUTTON_RELEASE) {
731 switch (ev->button) {
733 gain_astyle_menu.popup (1, ev->time);
742 GainMeterBase::astate_string (AutoState state)
744 return _astate_string (state, false);
748 GainMeterBase::short_astate_string (AutoState state)
750 return _astate_string (state, true);
754 GainMeterBase::_astate_string (AutoState state, bool shrt)
760 sstr = (shrt ? "M" : _("M"));
763 sstr = (shrt ? "P" : _("P"));
766 sstr = (shrt ? "T" : _("T"));
769 sstr = (shrt ? "W" : _("W"));
777 GainMeterBase::astyle_string (AutoStyle style)
779 return _astyle_string (style, false);
783 GainMeterBase::short_astyle_string (AutoStyle style)
785 return _astyle_string (style, true);
789 GainMeterBase::_astyle_string (AutoStyle style, bool shrt)
794 /* XXX it might different in different languages */
796 return (shrt ? _("Abs") : _("Abs"));
801 GainMeterBase::gain_automation_style_changed ()
805 gain_automation_style_button.set_text (astyle_string(_amp->gain_control()->alist()->automation_style()));
808 gain_automation_style_button.set_text (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
814 GainMeterBase::gain_automation_state_changed ()
816 ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed)
822 gain_automation_state_button.set_text (astate_string(_amp->gain_control()->alist()->automation_state()));
825 gain_automation_state_button.set_text (short_astate_string(_amp->gain_control()->alist()->automation_state()));
829 x = (_amp->gain_control()->alist()->automation_state() != ARDOUR::Off);
831 if (gain_automation_state_button.get_active() != x) {
832 ignore_toggle = true;
833 gain_automation_state_button.set_active (x);
834 ignore_toggle = false;
837 update_gain_sensitive ();
839 /* start watching automation so that things move */
841 gain_watching.disconnect();
844 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
849 GainMeterBase::update_meters()
852 float mpeak = level_meter->update_meters();
854 if (mpeak > max_peak) {
856 if (mpeak <= -200.0f) {
857 peak_display.set_text (_("-inf"));
859 snprintf (buf, sizeof(buf), "%.1f", mpeak);
860 peak_display.set_text (buf);
863 if (mpeak >= Config->get_meter_peak()) {
864 peak_display.set_name ("MixerStripPeakDisplayPeak");
868 void GainMeterBase::color_handler(bool /*dpi*/)
874 GainMeterBase::set_width (Width w, int len)
878 if (_width == Wide && _route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
881 level_meter->setup_meters(len, meter_width);
886 GainMeterBase::on_theme_changed()
891 GainMeterBase::redraw_metrics()
893 meter_metric_area.queue_draw ();
894 meter_ticks1_area.queue_draw ();
895 meter_ticks2_area.queue_draw ();
898 GainMeter::GainMeter (Session* s, int fader_length)
899 : GainMeterBase (s, false, fader_length, 24)
900 , gain_display_box(true, 0)
903 if (gain_display.get_parent()) {
904 gain_display.get_parent()->remove (gain_display);
906 gain_display_box.pack_start (gain_display, true, true);
908 if (peak_display.get_parent()) {
909 peak_display.get_parent()->remove (gain_display);
911 gain_display_box.pack_start (peak_display, true, true);
913 meter_metric_area.set_name ("AudioTrackMetrics");
914 meter_metric_area.set_size_request(24, -1);
916 gain_automation_style_button.set_name ("mixer strip button");
917 gain_automation_state_button.set_name ("mixer strip button");
919 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
920 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
922 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
923 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
925 gain_automation_state_button.set_size_request(15, 15);
926 gain_automation_style_button.set_size_request(15, 15);
928 fader_vbox = manage (new Gtk::VBox());
929 fader_vbox->set_spacing (0);
930 fader_vbox->pack_start (*gain_slider, true, true);
932 fader_alignment.set (0.5, 0.5, 0.0, 1.0);
933 fader_alignment.add (*fader_vbox);
935 hbox.pack_start (fader_alignment, true, true);
939 pack_start (gain_display_box, Gtk::PACK_SHRINK);
940 pack_start (hbox, Gtk::PACK_SHRINK);
942 meter_alignment.set (0.5, 0.5, 0.0, 1.0);
943 meter_alignment.add (*level_meter);
945 meter_metric_area.signal_expose_event().connect (
946 sigc::mem_fun(*this, &GainMeter::meter_metrics_expose));
948 meter_ticks1_area.set_size_request(3,-1);
949 meter_ticks2_area.set_size_request(3,-1);
951 meter_ticks1_area.signal_expose_event().connect (
952 sigc::mem_fun(*this, &GainMeter::meter_ticks1_expose));
953 meter_ticks2_area.signal_expose_event().connect (
954 sigc::mem_fun(*this, &GainMeter::meter_ticks2_expose));
956 meter_hbox.pack_start (meter_ticks1_area, false, false);
957 meter_hbox.pack_start (meter_alignment, false, false);
958 meter_hbox.pack_start (meter_ticks2_area, false, false);
959 meter_hbox.pack_start (meter_metric_area, false, false);
962 GainMeter::~GainMeter () { }
965 GainMeter::set_controls (boost::shared_ptr<Route> r,
966 boost::shared_ptr<PeakMeter> meter,
967 boost::shared_ptr<Amp> amp)
969 if (meter_hbox.get_parent()) {
970 hbox.remove (meter_hbox);
973 // if (gain_automation_state_button.get_parent()) {
974 // fader_vbox->remove (gain_automation_state_button);
977 GainMeterBase::set_controls (r, meter, amp);
980 _meter->ConfigurationChanged.connect (
981 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
983 _meter->TypeChanged.connect (
984 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_type_changed, this, _1), gui_context()
987 meter_configuration_changed (_meter->input_streams ());
992 _route->active_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::route_active_changed, this), gui_context ());
996 if we have a non-hidden route (ie. we're not the click or the auditioner),
997 pack some route-dependent stuff.
1000 hbox.pack_start (meter_hbox, true, true);
1002 // if (r && !r->is_auditioner()) {
1003 // fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
1011 GainMeter::get_gm_width ()
1013 Gtk::Requisition sz;
1016 meter_metric_area.size_request (sz);
1018 level_meter->size_request (sz);
1021 fader_alignment.size_request (sz);
1023 return max(sz.width * 2, min_w * 2) + 6;
1025 return sz.width + min_w + 6;
1030 GainMeter::meter_metrics_expose (GdkEventExpose *ev)
1033 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1034 return meter_expose_metrics(ev, MeterPeak, _types, &meter_metric_area);
1036 return meter_expose_metrics(ev, _route->meter_type(), _types, &meter_metric_area);
1040 GainMeter::meter_ticks1_expose (GdkEventExpose *ev)
1043 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1044 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks1_area);
1046 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks1_area);
1050 GainMeter::meter_ticks2_expose (GdkEventExpose *ev)
1053 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1054 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks2_area);
1056 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks2_area);
1060 GainMeter::on_style_changed (const Glib::RefPtr<Gtk::Style>&)
1062 gain_display.queue_draw();
1063 peak_display.queue_draw();
1066 boost::shared_ptr<PBD::Controllable>
1067 GainMeterBase::get_controllable()
1070 return _amp->gain_control();
1072 return boost::shared_ptr<PBD::Controllable>();
1077 GainMeterBase::level_meter_button_press (GdkEventButton* ev)
1079 return !!LevelMeterButtonPress (ev); /* EMIT SIGNAL */
1083 GainMeter::meter_configuration_changed (ChanCount c)
1088 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
1089 if (c.get (*i) > 0) {
1090 _types.push_back (*i);
1096 && boost::dynamic_pointer_cast<AudioTrack>(_route) == 0
1097 && boost::dynamic_pointer_cast<MidiTrack>(_route) == 0
1099 if (_route->active()) {
1100 set_meter_strip_name ("AudioBusMetrics");
1102 set_meter_strip_name ("AudioBusMetricsInactive");
1106 (type == (1 << DataType::MIDI))
1107 || (_route && boost::dynamic_pointer_cast<MidiTrack>(_route))
1109 if (!_route || _route->active()) {
1110 set_meter_strip_name ("MidiTrackMetrics");
1112 set_meter_strip_name ("MidiTrackMetricsInactive");
1115 else if (type == (1 << DataType::AUDIO)) {
1116 if (!_route || _route->active()) {
1117 set_meter_strip_name ("AudioTrackMetrics");
1119 set_meter_strip_name ("AudioTrackMetricsInactive");
1122 if (!_route || _route->active()) {
1123 set_meter_strip_name ("AudioMidiTrackMetrics");
1125 set_meter_strip_name ("AudioMidiTrackMetricsInactive");
1130 meter_clear_pattern_cache(4);
1131 on_style_changed(Glib::RefPtr<Gtk::Style>());
1135 GainMeter::route_active_changed ()
1138 meter_configuration_changed (_meter->input_streams ());
1143 GainMeter::meter_type_changed (MeterType t)
1145 _route->set_meter_type(t);