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"
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"
53 #include "ardour/dB.h"
57 using namespace ARDOUR;
58 using namespace ARDOUR_UI_UTILS;
60 using namespace Gtkmm2ext;
63 using Gtkmm2ext::Keyboard;
64 using namespace ArdourMeter;
68 reset_cursor_to_default (Gtk::Entry* widget)
70 Glib::RefPtr<Gdk::Window> win = widget->get_text_window ();
72 /* C++ doesn't provide a pointer argument version of this
73 (i.e. you cannot set to NULL to get the default/parent
76 gdk_window_set_cursor (win->gobj(), 0);
81 reset_cursor_to_default_state (Gtk::StateType, Gtk::Entry* widget)
83 reset_cursor_to_default (widget);
86 GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int fader_girth)
87 : gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), // value
90 dB_coeff_step(Config->get_max_gain()) / 10.0, // step increment
91 dB_coeff_step(Config->get_max_gain())) // page increment
92 , gain_automation_style_button ("")
93 , gain_automation_state_button ("")
94 , _data_type (DataType::AUDIO)
96 using namespace Menu_Helpers;
100 ignore_toggle = false;
102 next_release_selects = false;
106 gain_slider = manage (new HSliderController (&gain_adjustment, boost::shared_ptr<PBD::Controllable>(), fader_length, fader_girth));
108 gain_slider = manage (new VSliderController (&gain_adjustment, boost::shared_ptr<PBD::Controllable>(), fader_length, fader_girth));
111 level_meter = new LevelMeterHBox(_session);
113 level_meter->ButtonPress.connect_same_thread (_level_meter_connection, boost::bind (&GainMeterBase::level_meter_button_press, this, _1));
114 meter_metric_area.signal_button_press_event().connect (sigc::mem_fun (*this, &GainMeterBase::level_meter_button_press));
115 meter_metric_area.add_events (Gdk::BUTTON_PRESS_MASK);
117 gain_slider->set_tweaks (PixFader::Tweaks(PixFader::NoButtonForward | PixFader::NoVerticalScroll));
118 gain_slider->StartGesture.connect (sigc::mem_fun (*this, &GainMeter::amp_start_touch));
119 gain_slider->StopGesture.connect (sigc::mem_fun (*this, &GainMeter::amp_stop_touch));
120 gain_slider->set_name ("GainFader");
122 gain_display.set_name ("MixerStripGainDisplay");
123 set_size_request_to_display_given_text (gain_display, "-80.g", 2, 6); /* note the descender */
124 gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
125 gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
126 gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
127 gain_display.set_alignment(0.5);
129 peak_display.set_name ("MixerStripPeakDisplay");
130 set_size_request_to_display_given_text (peak_display, "-80.g", 2, 6); /* note the descender */
131 max_peak = minus_infinity();
132 peak_display.set_text (_("-inf"));
133 peak_display.set_alignment(0.5);
135 /* stuff related to the fact that the peak display is not, in
136 fact, supposed to be a text entry.
138 peak_display.set_events (peak_display.get_events() & ~(Gdk::EventMask (Gdk::LEAVE_NOTIFY_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::POINTER_MOTION_MASK)));
139 peak_display.signal_map().connect (sigc::bind (sigc::ptr_fun (reset_cursor_to_default), &peak_display));
140 peak_display.signal_state_changed().connect (sigc::bind (sigc::ptr_fun (reset_cursor_to_default_state), &peak_display));
141 peak_display.unset_flags (Gtk::CAN_FOCUS);
142 peak_display.set_editable (false);
144 gain_automation_style_button.set_name ("mixer strip button");
145 gain_automation_state_button.set_name ("mixer strip button");
147 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
148 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
150 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
151 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
153 gain_automation_state_button.set_size_request(15, 15);
154 gain_automation_style_button.set_size_request(15, 15);
156 gain_astyle_menu.items().push_back (MenuElem (_("Trim")));
157 gain_astyle_menu.items().push_back (MenuElem (_("Abs")));
159 gain_astate_menu.set_name ("ArdourContextMenu");
160 gain_astyle_menu.set_name ("ArdourContextMenu");
162 gain_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &GainMeterBase::gain_adjusted));
163 peak_display.signal_button_release_event().connect (sigc::mem_fun(*this, &GainMeterBase::peak_button_release), false);
164 gain_display.signal_key_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_key_press), false);
166 ResetAllPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_peak_display));
167 ResetRoutePeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_route_peak_display));
168 ResetGroupPeakDisplays.connect (sigc::mem_fun(*this, &GainMeterBase::reset_group_peak_display));
169 RedrawMetrics.connect (sigc::mem_fun(*this, &GainMeterBase::redraw_metrics));
171 UI::instance()->theme_changed.connect (sigc::mem_fun(*this, &GainMeterBase::on_theme_changed));
172 ColorsChanged.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), false));
173 DPIReset.connect (sigc::bind(sigc::mem_fun (*this, &GainMeterBase::color_handler), true));
176 GainMeterBase::~GainMeterBase ()
183 GainMeterBase::set_controls (boost::shared_ptr<Route> r,
184 boost::shared_ptr<PeakMeter> pm,
185 boost::shared_ptr<Amp> amp)
187 connections.clear ();
188 model_connections.drop_connections ();
191 level_meter->set_meter (0);
192 gain_slider->set_controllable (boost::shared_ptr<PBD::Controllable>());
203 level_meter->set_meter (pm.get());
204 gain_slider->set_controllable (amp->gain_control());
207 amp->ConfigurationChanged.connect (
208 model_connections, invalidator (*this), boost::bind (&GainMeterBase::setup_gain_adjustment, this), gui_context ()
212 setup_gain_adjustment ();
214 if (!_route || !_route->is_auditioner()) {
216 using namespace Menu_Helpers;
218 gain_astate_menu.items().clear ();
220 gain_astate_menu.items().push_back (MenuElem (S_("Automation|Manual"),
221 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
222 Evoral::Parameter(GainAutomation), (AutoState) ARDOUR::Off)));
223 gain_astate_menu.items().push_back (MenuElem (_("Play"),
224 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
225 Evoral::Parameter(GainAutomation), (AutoState) Play)));
226 gain_astate_menu.items().push_back (MenuElem (_("Write"),
227 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
228 Evoral::Parameter(GainAutomation), (AutoState) Write)));
229 gain_astate_menu.items().push_back (MenuElem (_("Touch"),
230 sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
231 Evoral::Parameter(GainAutomation), (AutoState) Touch)));
233 connections.push_back (gain_automation_style_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_style_button_event), false));
234 connections.push_back (gain_automation_state_button.signal_button_press_event().connect (sigc::mem_fun(*this, &GainMeterBase::gain_automation_state_button_event), false));
236 boost::shared_ptr<AutomationControl> gc = amp->gain_control();
238 gc->alist()->automation_state_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_state_changed, this), gui_context());
239 gc->alist()->automation_style_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::gain_automation_style_changed, this), gui_context());
241 gain_automation_state_changed ();
244 amp->gain_control()->Changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeterBase::gain_changed, this), gui_context());
248 update_gain_sensitive ();
252 GainMeterBase::setup_gain_adjustment ()
258 if (_previous_amp_output_streams == _amp->output_streams ()) {
262 ignore_toggle = true;
264 if (_amp->output_streams().n_midi() <= _amp->output_streams().n_audio()) {
265 _data_type = DataType::AUDIO;
266 gain_adjustment.set_lower (0.0);
267 gain_adjustment.set_upper (1.0);
268 gain_adjustment.set_step_increment (dB_coeff_step(Config->get_max_gain()) / 10.0);
269 gain_adjustment.set_page_increment (dB_coeff_step(Config->get_max_gain()));
270 gain_slider->set_default_value (gain_to_slider_position (1));
272 _data_type = DataType::MIDI;
273 gain_adjustment.set_lower (0.0);
274 gain_adjustment.set_upper (2.0);
275 gain_adjustment.set_step_increment (1.0/128.0);
276 gain_adjustment.set_page_increment (10.0/128.0);
277 gain_slider->set_default_value (1.0);
280 ignore_toggle = false;
282 effective_gain_display ();
284 _previous_amp_output_streams = _amp->output_streams ();
288 GainMeterBase::hide_all_meters ()
290 level_meter->hide_meters();
294 GainMeter::hide_all_meters ()
296 GainMeterBase::hide_all_meters ();
300 GainMeterBase::setup_meters (int len)
303 uint32_t meter_channels = 0;
305 meter_channels = _meter->input_streams().n_total();
307 meter_channels = _route->shared_peak_meter()->input_streams().n_total();
312 //meter_ticks1_area.show();
313 //meter_ticks2_area.show();
314 meter_metric_area.show();
315 if (meter_channels == 1) {
320 if (meter_channels > 1) {
323 //meter_ticks1_area.hide();
324 //meter_ticks2_area.hide();
325 meter_metric_area.hide();
328 level_meter->setup_meters(len, meter_width);
332 GainMeterBase::set_type (MeterType t)
334 level_meter->set_type(t);
338 GainMeter::setup_meters (int len)
343 uint32_t meter_channels = 0;
345 meter_channels = _meter->input_streams().n_total();
347 meter_channels = _route->shared_peak_meter()->input_streams().n_total();
349 hbox.set_homogeneous(meter_channels < 7 ? true : false);
353 hbox.set_homogeneous(false);
356 GainMeterBase::setup_meters (len);
360 GainMeter::set_type (MeterType t)
362 GainMeterBase::set_type (t);
366 GainMeterBase::gain_key_press (GdkEventKey* ev)
368 if (key_is_legal_for_numeric_entry (ev->keyval)) {
369 /* drop through to normal handling */
372 /* illegal key for gain entry */
377 GainMeterBase::peak_button_release (GdkEventButton* ev)
379 /* reset peak label */
381 if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
382 ResetAllPeakDisplays ();
383 } else if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
385 ResetGroupPeakDisplays (_route->route_group());
388 ResetRoutePeakDisplays (_route.get());
395 GainMeterBase::reset_peak_display ()
398 level_meter->clear_meters();
399 max_peak = -INFINITY;
400 peak_display.set_text (_("-inf"));
401 peak_display.set_name ("MixerStripPeakDisplay");
405 GainMeterBase::reset_route_peak_display (Route* route)
407 if (_route && _route.get() == route) {
408 reset_peak_display ();
413 GainMeterBase::reset_group_peak_display (RouteGroup* group)
415 if (_route && group == _route->route_group()) {
416 reset_peak_display ();
421 GainMeterBase::popup_meter_menu (GdkEventButton *ev)
423 using namespace Menu_Helpers;
425 if (meter_menu == 0) {
426 meter_menu = new Gtk::Menu;
427 MenuList& items = meter_menu->items();
429 items.push_back (MenuElem ("-inf .. +0dBFS"));
430 items.push_back (MenuElem ("-10dB .. +0dBFS"));
431 items.push_back (MenuElem ("-4 .. +0dBFS"));
432 items.push_back (SeparatorElem());
433 items.push_back (MenuElem ("-inf .. -2dBFS"));
434 items.push_back (MenuElem ("-10dB .. -2dBFS"));
435 items.push_back (MenuElem ("-4 .. -2dBFS"));
438 meter_menu->popup (1, ev->time);
442 GainMeterBase::gain_focused (GdkEventFocus* ev)
445 gain_display.select_region (0, -1);
447 gain_display.select_region (0, 0);
453 GainMeterBase::gain_activated ()
458 // Switch to user's preferred locale so that
459 // if they use different LC_NUMERIC conventions,
460 // we will honor them.
462 PBD::LocaleGuard lg ("");
463 if (sscanf (gain_display.get_text().c_str(), "%f", &f) != 1) {
468 /* clamp to displayable values */
469 if (_data_type == DataType::AUDIO) {
471 _amp->set_gain (dB_to_coefficient(f), this);
473 f = min (fabs (f), 2.0f);
474 _amp->set_gain (f, this);
477 if (gain_display.has_focus()) {
478 Gtk::Widget* w = gain_display.get_toplevel();
480 Gtk::Window* win = dynamic_cast<Gtk::Window*> (w);
482 /* sigh. gtkmm doesn't wrap get_default_widget() */
485 GtkWidget* f = gtk_window_get_default_widget (win->gobj());
487 gtk_widget_grab_focus (f);
496 GainMeterBase::show_gain ()
500 float v = gain_adjustment.get_value();
502 switch (_data_type) {
503 case DataType::AUDIO:
505 strcpy (buf, _("-inf"));
507 snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (v, Config->get_max_gain())));
511 snprintf (buf, sizeof (buf), "%.1f", v);
515 gain_display.set_text (buf);
519 GainMeterBase::gain_adjusted ()
523 /* convert from adjustment range (0..1) to gain coefficient */
525 if (_data_type == DataType::AUDIO) {
526 value = slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain());
528 value = gain_adjustment.get_value();
531 if (!ignore_toggle) {
532 if (_route && _route->amp() == _amp) {
533 _route->set_gain (value, this);
535 _amp->set_gain (value, this);
543 GainMeterBase::effective_gain_display ()
547 switch (_data_type) {
548 case DataType::AUDIO:
549 value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain());
552 value = _amp->gain ();
556 if (gain_adjustment.get_value() != value) {
557 ignore_toggle = true;
558 gain_adjustment.set_value (value);
559 ignore_toggle = false;
564 GainMeterBase::gain_changed ()
566 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&GainMeterBase::effective_gain_display, this));
570 GainMeterBase::set_meter_strip_name (const char * name)
573 meter_metric_area.set_name (name);
574 sprintf(tmp, "Mark%sLeft", name);
575 meter_ticks1_area.set_name (tmp);
576 sprintf(tmp, "Mark%sRight", name);
577 meter_ticks2_area.set_name (tmp);
581 GainMeterBase::set_fader_name (const char * name)
583 gain_slider->set_name (name);
587 GainMeterBase::update_gain_sensitive ()
589 bool x = !(_amp->gain_control()->alist()->automation_state() & Play);
590 static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (x);
594 next_meter_point (MeterPoint mp)
598 return MeterPreFader;
602 return MeterPostFader;
618 abort(); /*NOTREACHED*/
623 GainMeterBase::meter_press(GdkEventButton* ev)
625 wait_for_release = false;
631 if (!ignore_toggle) {
633 if (Keyboard::is_context_menu_event (ev)) {
635 // no menu at this time.
639 if (Keyboard::is_button2_event(ev)) {
641 // Primary-button2 click is the midi binding click
642 // button2-click is "momentary"
644 if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) {
645 wait_for_release = true;
646 old_meter_point = _route->meter_point ();
650 if (_route && (ev->button == 1 || Keyboard::is_button2_event (ev))) {
652 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
654 /* Primary+Tertiary-click applies change to all routes */
656 _session->foreach_route (this, &GainMeterBase::set_meter_point, next_meter_point (_route->meter_point()));
659 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
661 /* Primary-click: solo mix group.
662 NOTE: Primary-button2 is MIDI learn.
665 if (ev->button == 1) {
666 set_route_group_meter_point (*_route, next_meter_point (_route->meter_point()));
671 /* click: change just this route */
675 _route->set_meter_point (next_meter_point (_route->meter_point()));
686 GainMeterBase::meter_release(GdkEventButton*)
688 if (!ignore_toggle) {
689 if (wait_for_release) {
690 wait_for_release = false;
693 set_meter_point (*_route, old_meter_point);
702 GainMeterBase::set_meter_point (Route& route, MeterPoint mp)
704 route.set_meter_point (mp);
708 GainMeterBase::set_route_group_meter_point (Route& route, MeterPoint mp)
710 RouteGroup* route_group;
712 if ((route_group = route.route_group ()) != 0) {
713 route_group->foreach_route (boost::bind (&Route::set_meter_point, _1, mp, false));
715 route.set_meter_point (mp);
720 GainMeterBase::meter_point_clicked ()
728 GainMeterBase::amp_start_touch ()
730 _amp->gain_control()->start_touch (_amp->session().transport_frame());
734 GainMeterBase::amp_stop_touch ()
736 _amp->gain_control()->stop_touch (false, _amp->session().transport_frame());
740 GainMeterBase::gain_automation_state_button_event (GdkEventButton *ev)
742 if (ev->type == GDK_BUTTON_RELEASE) {
746 switch (ev->button) {
748 gain_astate_menu.popup (1, ev->time);
758 GainMeterBase::gain_automation_style_button_event (GdkEventButton *ev)
760 if (ev->type == GDK_BUTTON_RELEASE) {
764 switch (ev->button) {
766 gain_astyle_menu.popup (1, ev->time);
775 GainMeterBase::astate_string (AutoState state)
777 return _astate_string (state, false);
781 GainMeterBase::short_astate_string (AutoState state)
783 return _astate_string (state, true);
787 GainMeterBase::_astate_string (AutoState state, bool shrt)
793 sstr = (shrt ? "M" : _("M"));
796 sstr = (shrt ? "P" : _("P"));
799 sstr = (shrt ? "T" : _("T"));
802 sstr = (shrt ? "W" : _("W"));
810 GainMeterBase::astyle_string (AutoStyle style)
812 return _astyle_string (style, false);
816 GainMeterBase::short_astyle_string (AutoStyle style)
818 return _astyle_string (style, true);
822 GainMeterBase::_astyle_string (AutoStyle style, bool shrt)
827 /* XXX it might different in different languages */
829 return (shrt ? _("Abs") : _("Abs"));
834 GainMeterBase::gain_automation_style_changed ()
838 gain_automation_style_button.set_text (astyle_string(_amp->gain_control()->alist()->automation_style()));
841 gain_automation_style_button.set_text (short_astyle_string(_amp->gain_control()->alist()->automation_style()));
847 GainMeterBase::gain_automation_state_changed ()
849 ENSURE_GUI_THREAD (*this, &GainMeterBase::gain_automation_state_changed)
855 gain_automation_state_button.set_text (astate_string(_amp->gain_control()->alist()->automation_state()));
858 gain_automation_state_button.set_text (short_astate_string(_amp->gain_control()->alist()->automation_state()));
862 x = (_amp->gain_control()->alist()->automation_state() != ARDOUR::Off);
864 if (gain_automation_state_button.get_active() != x) {
865 ignore_toggle = true;
866 gain_automation_state_button.set_active (x);
867 ignore_toggle = false;
870 update_gain_sensitive ();
872 /* start watching automation so that things move */
874 gain_watching.disconnect();
877 gain_watching = Timers::rapid_connect (sigc::mem_fun (*this, &GainMeterBase::effective_gain_display));
882 GainMeterBase::meter_channels() const
884 if (_meter) { return _meter->input_streams(); }
885 else { return ChanCount(); }
888 GainMeterBase::update_meters()
891 float mpeak = level_meter->update_meters();
893 if (mpeak > max_peak) {
895 if (mpeak <= -200.0f) {
896 peak_display.set_text (_("-inf"));
898 snprintf (buf, sizeof(buf), "%.1f", mpeak);
899 peak_display.set_text (buf);
902 if (mpeak >= ARDOUR_UI::config()->get_meter_peak()) {
903 peak_display.set_name ("MixerStripPeakDisplayPeak");
907 void GainMeterBase::color_handler(bool /*dpi*/)
913 GainMeterBase::set_width (Width w, int len)
917 if (_width == Wide && _route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
920 level_meter->setup_meters(len, meter_width);
925 GainMeterBase::on_theme_changed()
930 GainMeterBase::redraw_metrics()
932 meter_metric_area.queue_draw ();
933 meter_ticks1_area.queue_draw ();
934 meter_ticks2_area.queue_draw ();
937 GainMeter::GainMeter (Session* s, int fader_length)
938 : GainMeterBase (s, false, fader_length, 24)
939 , gain_display_box(true, 0)
942 if (gain_display.get_parent()) {
943 gain_display.get_parent()->remove (gain_display);
945 gain_display_box.pack_start (gain_display, true, true);
947 if (peak_display.get_parent()) {
948 peak_display.get_parent()->remove (gain_display);
950 gain_display_box.pack_start (peak_display, true, true);
952 meter_metric_area.set_name ("AudioTrackMetrics");
953 meter_metric_area.set_size_request(24, -1);
955 gain_automation_style_button.set_name ("mixer strip button");
956 gain_automation_state_button.set_name ("mixer strip button");
958 ARDOUR_UI::instance()->set_tip (gain_automation_state_button, _("Fader automation mode"));
959 ARDOUR_UI::instance()->set_tip (gain_automation_style_button, _("Fader automation type"));
961 gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
962 gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
964 gain_automation_state_button.set_size_request(15, 15);
965 gain_automation_style_button.set_size_request(15, 15);
967 fader_vbox = manage (new Gtk::VBox());
968 fader_vbox->set_spacing (0);
969 fader_vbox->pack_start (*gain_slider, true, true);
971 fader_alignment.set (0.5, 0.5, 0.0, 1.0);
972 fader_alignment.add (*fader_vbox);
974 hbox.pack_start (fader_alignment, true, true);
978 pack_start (gain_display_box, Gtk::PACK_SHRINK);
979 pack_start (hbox, Gtk::PACK_SHRINK);
981 meter_alignment.set (0.5, 0.5, 0.0, 1.0);
982 meter_alignment.add (*level_meter);
984 meter_metric_area.signal_expose_event().connect (
985 sigc::mem_fun(*this, &GainMeter::meter_metrics_expose));
987 meter_ticks1_area.set_size_request(3,-1);
988 meter_ticks2_area.set_size_request(3,-1);
990 meter_ticks1_area.signal_expose_event().connect (
991 sigc::mem_fun(*this, &GainMeter::meter_ticks1_expose));
992 meter_ticks2_area.signal_expose_event().connect (
993 sigc::mem_fun(*this, &GainMeter::meter_ticks2_expose));
995 meter_hbox.pack_start (meter_ticks1_area, false, false);
996 meter_hbox.pack_start (meter_alignment, false, false);
997 meter_hbox.pack_start (meter_ticks2_area, false, false);
998 meter_hbox.pack_start (meter_metric_area, false, false);
1001 GainMeter::~GainMeter () { }
1004 GainMeter::set_controls (boost::shared_ptr<Route> r,
1005 boost::shared_ptr<PeakMeter> meter,
1006 boost::shared_ptr<Amp> amp)
1008 if (meter_hbox.get_parent()) {
1009 hbox.remove (meter_hbox);
1012 // if (gain_automation_state_button.get_parent()) {
1013 // fader_vbox->remove (gain_automation_state_button);
1016 GainMeterBase::set_controls (r, meter, amp);
1019 _meter->ConfigurationChanged.connect (
1020 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_configuration_changed, this, _1), gui_context()
1022 _meter->TypeChanged.connect (
1023 model_connections, invalidator (*this), boost::bind (&GainMeter::meter_type_changed, this, _1), gui_context()
1026 meter_configuration_changed (_meter->input_streams ());
1031 _route->active_changed.connect (model_connections, invalidator (*this), boost::bind (&GainMeter::route_active_changed, this), gui_context ());
1035 if we have a non-hidden route (ie. we're not the click or the auditioner),
1036 pack some route-dependent stuff.
1039 hbox.pack_start (meter_hbox, true, true);
1041 // if (r && !r->is_auditioner()) {
1042 // fader_vbox->pack_start (gain_automation_state_button, false, false, 0);
1050 GainMeter::get_gm_width ()
1052 Gtk::Requisition sz;
1055 meter_metric_area.size_request (sz);
1057 level_meter->size_request (sz);
1060 fader_alignment.size_request (sz);
1062 return max(sz.width * 2, min_w * 2) + 6;
1064 return sz.width + min_w + 6;
1069 GainMeter::meter_metrics_expose (GdkEventExpose *ev)
1072 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1073 return meter_expose_metrics(ev, MeterPeak, _types, &meter_metric_area);
1075 return meter_expose_metrics(ev, _route->meter_type(), _types, &meter_metric_area);
1079 GainMeter::meter_ticks1_expose (GdkEventExpose *ev)
1082 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1083 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks1_area);
1085 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks1_area);
1089 GainMeter::meter_ticks2_expose (GdkEventExpose *ev)
1092 if (_types.empty()) { _types.push_back(DataType::AUDIO); }
1093 return meter_expose_ticks(ev, MeterPeak, _types, &meter_ticks2_area);
1095 return meter_expose_ticks(ev, _route->meter_type(), _types, &meter_ticks2_area);
1099 GainMeter::on_style_changed (const Glib::RefPtr<Gtk::Style>&)
1101 gain_display.queue_draw();
1102 peak_display.queue_draw();
1105 boost::shared_ptr<PBD::Controllable>
1106 GainMeterBase::get_controllable()
1109 return _amp->gain_control();
1111 return boost::shared_ptr<PBD::Controllable>();
1116 GainMeterBase::level_meter_button_press (GdkEventButton* ev)
1118 return !!LevelMeterButtonPress (ev); /* EMIT SIGNAL */
1122 GainMeter::meter_configuration_changed (ChanCount c)
1127 for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
1128 if (c.get (*i) > 0) {
1129 _types.push_back (*i);
1135 && boost::dynamic_pointer_cast<AudioTrack>(_route) == 0
1136 && boost::dynamic_pointer_cast<MidiTrack>(_route) == 0
1138 if (_route->active()) {
1139 set_meter_strip_name ("AudioBusMetrics");
1141 set_meter_strip_name ("AudioBusMetricsInactive");
1145 (type == (1 << DataType::MIDI))
1146 || (_route && boost::dynamic_pointer_cast<MidiTrack>(_route))
1148 if (!_route || _route->active()) {
1149 set_meter_strip_name ("MidiTrackMetrics");
1151 set_meter_strip_name ("MidiTrackMetricsInactive");
1154 else if (type == (1 << DataType::AUDIO)) {
1155 if (!_route || _route->active()) {
1156 set_meter_strip_name ("AudioTrackMetrics");
1158 set_meter_strip_name ("AudioTrackMetricsInactive");
1161 if (!_route || _route->active()) {
1162 set_meter_strip_name ("AudioMidiTrackMetrics");
1164 set_meter_strip_name ("AudioMidiTrackMetricsInactive");
1169 meter_clear_pattern_cache(4);
1170 on_style_changed(Glib::RefPtr<Gtk::Style>());
1174 GainMeter::route_active_changed ()
1177 meter_configuration_changed (_meter->input_streams ());
1182 GainMeter::meter_type_changed (MeterType t)
1184 _route->set_meter_type(t);