diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-19 23:02:55 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-06-19 23:02:55 +0000 |
commit | d5e09076ca69fda1402a12e383de7a7d9bc5f0ec (patch) | |
tree | 0d4df7147098ea57e58d96efb82f57dd5545023c /gtk2_ardour | |
parent | 182b23e744d79b3387a779ea25010924daffe6af (diff) |
much ado about nothing when it comes to gain control
git-svn-id: svn://localhost/ardour2/branches/3.0@9748 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour3_styles.rc.in | 6 | ||||
-rw-r--r-- | gtk2_ardour/ardour3_widget_list.rc | 3 | ||||
-rw-r--r-- | gtk2_ardour/automation_line.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 7 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.cc | 23 | ||||
-rw-r--r-- | gtk2_ardour/monitor_section.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/option_editor.cc | 10 | ||||
-rw-r--r-- | gtk2_ardour/processor_box.cc | 9 | ||||
-rw-r--r-- | gtk2_ardour/volume_controller.cc | 61 | ||||
-rw-r--r-- | gtk2_ardour/volume_controller.h | 8 |
11 files changed, 84 insertions, 67 deletions
diff --git a/gtk2_ardour/ardour3_styles.rc.in b/gtk2_ardour/ardour3_styles.rc.in index f8afec52b1..6deddf7c11 100644 --- a/gtk2_ardour/ardour3_styles.rc.in +++ b/gtk2_ardour/ardour3_styles.rc.in @@ -571,7 +571,7 @@ style "medium_entry" = "medium_text" fg[ACTIVE] = @@COLPREFIX@_text fg[SELECTED] = @@COLPREFIX@_fg_selected - bg[NORMAL] = @@COLPREFIX@_bg + bg[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base @@ -593,7 +593,7 @@ style "medium_bold_entry" = "medium_bold_text" fg[NORMAL] = @@COLPREFIX@_text fg[ACTIVE] = @@COLPREFIX@_text - bg[NORMAL] = @@COLPREFIX@_bg + bg[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base @@ -627,7 +627,7 @@ style "small_bold_entry" = "small_bold_text" fg[NORMAL] = @@COLPREFIX@_text fg[ACTIVE] = @@COLPREFIX@_text - bg[NORMAL] = @@COLPREFIX@_bg + bg[NORMAL] = @@COLPREFIX@_base base[NORMAL] = @@COLPREFIX@_base base[ACTIVE] = @@COLPREFIX@_base diff --git a/gtk2_ardour/ardour3_widget_list.rc b/gtk2_ardour/ardour3_widget_list.rc index 8c49427f6a..e85532515d 100644 --- a/gtk2_ardour/ardour3_widget_list.rc +++ b/gtk2_ardour/ardour3_widget_list.rc @@ -237,7 +237,8 @@ widget "*PluginParameterLabel" style:highest "medium_text" widget "*PluginNameInfo" style:highest "plugin_name_text" widget "*PluginMakerInfo" style:highest "plugin_maker_text" widget "*PluginParameterInfo" style:highest "medium_text" -widget "*MotionControllerValue" style:highest "medium_entry" +widget "*MotionControllerValue" style:highest "small_entry" +widget "*MotionControllerValue*" style:highest "small_entry" widget "*ParameterValueDisplay" style:highest "medium_bold_entry" widget "*PluginUIClickBox" style:highest "medium_bold_entry" widget "*PluginUIClickBox*" style:highest "medium_bold_entry" diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 9a5a9098c7..979b969621 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -521,7 +521,7 @@ AutomationLine::fraction_to_string (double fraction) const if (fraction == 0.0) { snprintf (buf, sizeof (buf), "-inf"); } else { - snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (fraction))); + snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (fraction, Config->get_max_gain()))); } } else { view_to_model_coord_y (fraction); @@ -551,7 +551,7 @@ AutomationLine::string_to_fraction (string const & s) const sscanf (s.c_str(), "%lf", &v); if (_uses_gain_mapping) { - v = gain_to_slider_position (dB_to_coefficient (v)); + v = gain_to_slider_position_with_max (dB_to_coefficient (v), Config->get_max_gain()); } else { double dummy = 0.0; model_to_view_coord (dummy, v); @@ -1198,7 +1198,7 @@ AutomationLine::view_to_model_coord_y (double& y) const /* TODO: This should be more generic ... */ if (alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation) { - y = slider_position_to_gain (y); + y = slider_position_to_gain_with_max (y, Config->get_max_gain()); y = max (0.0, y); y = min (2.0, y); } else if (alist->parameter().type() == PanAzimuthAutomation || @@ -1218,7 +1218,7 @@ AutomationLine::model_to_view_coord (double& x, double& y) const /* TODO: This should be more generic ... */ if (alist->parameter().type() == GainAutomation || alist->parameter().type() == EnvelopeAutomation) { - y = gain_to_slider_position (y); + y = gain_to_slider_position_with_max (y, Config->get_max_gain()); } else if (alist->parameter().type() == PanAzimuthAutomation || alist->parameter().type() == PanElevationAutomation || alist->parameter().type() == PanWidthAutomation) { diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 3be4e78db3..42765e1d87 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -66,14 +66,13 @@ using namespace ArdourCanvas; using Gtkmm2ext::Keyboard; -double const ControlPointDrag::_zero_gain_fraction = gain_to_slider_position (dB_to_coefficient (0.0)); +double ControlPointDrag::_zero_gain_fraction = -1.0; DragManager::DragManager (Editor* e) : _editor (e) , _ending (false) , _current_pointer_frame (0) { - } DragManager::~DragManager () @@ -2752,6 +2751,10 @@ ControlPointDrag::ControlPointDrag (Editor* e, ArdourCanvas::Item* i) _cumulative_x_drag (0), _cumulative_y_drag (0) { + if (_zero_gain_fraction < 0.0) { + _zero_gain_fraction = gain_to_slider_position_with_max (dB_to_coefficient (0.0), Config->get_max_gain()); + } + DEBUG_TRACE (DEBUG::Drags, "New ControlPointDrag\n"); _point = reinterpret_cast<ControlPoint*> (_item->get_data ("control_point")); diff --git a/gtk2_ardour/editor_drag.h b/gtk2_ardour/editor_drag.h index 113e54c88e..d4cd5a6a9d 100644 --- a/gtk2_ardour/editor_drag.h +++ b/gtk2_ardour/editor_drag.h @@ -690,7 +690,7 @@ private: double _fixed_grab_y; double _cumulative_x_drag; double _cumulative_y_drag; - static double const _zero_gain_fraction; + static double _zero_gain_fraction; }; /** Gain or automation line drag */ diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index f0a8ceb548..b671d5674a 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -79,7 +79,7 @@ GainMeterBase::GainMeterBase (Session* s, const Glib::RefPtr<Gdk::Pixbuf>& pix, bool horizontal, int fader_length) - : gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1) // 0.781787 is the value needed for gain to be set to 0. + : gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0.0, 1.0, 0.01, 0.1) , gain_automation_style_button ("") , gain_automation_state_button ("") , style_changed (false) @@ -382,7 +382,7 @@ GainMeterBase::show_gain () if (v == 0.0) { strcpy (buf, _("-inf")); } else { - snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain (v))); + snprintf (buf, sizeof (buf), "%.1f", accurate_coefficient_to_dB (slider_position_to_gain_with_max (v, Config->get_max_gain()))); } } else { snprintf (buf, sizeof (buf), "%.1f", v); @@ -395,14 +395,13 @@ void GainMeterBase::gain_adjusted () { if (!ignore_toggle) { - if (_route && _route->amp() == _amp) { - if (_is_midi) { - _route->set_gain (gain_adjustment.get_value(), this); - } else { - _route->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); - } + if (_is_midi) { + _amp->set_gain (gain_adjustment.get_value(), this); } else { - _amp->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); + cerr << "reset gain using slider pos " << gain_adjustment.get_value() << " to " + << slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain()) + << endl; + _amp->set_gain (slider_position_to_gain_with_max (gain_adjustment.get_value(), Config->get_max_gain()), this); } } @@ -415,15 +414,11 @@ GainMeterBase::effective_gain_display () gfloat value; if (!_route || _route->output()->n_ports().n_midi() == 0) { - value = gain_to_slider_position (_amp->gain()); + value = gain_to_slider_position_with_max (_amp->gain(), Config->get_max_gain()); } else { value = _amp->gain (); } - //cerr << this << " for " << _io->name() << " EGAIN = " << value - // << " AGAIN = " << gain_adjustment.get_value () << endl; - // stacktrace (cerr, 20); - if (gain_adjustment.get_value() != value) { ignore_toggle = true; gain_adjustment.set_value (value); diff --git a/gtk2_ardour/monitor_section.cc b/gtk2_ardour/monitor_section.cc index 9d1811b1d4..ecd1e5c259 100644 --- a/gtk2_ardour/monitor_section.cc +++ b/gtk2_ardour/monitor_section.cc @@ -70,12 +70,12 @@ MonitorSection::MonitorSection (Session* s) /* Dim */ - dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true, true); + dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true); HBox* dim_packer = manage (new HBox); dim_packer->show (); - spin_label = manage (new Label (_("Dim Cut"))); + spin_label = manage (new Label (_("Dim"))); spin_packer = manage (new VBox); spin_packer->show (); spin_packer->set_spacing (6); @@ -134,7 +134,7 @@ MonitorSection::MonitorSection (Session* s) /* Solo Boost */ - solo_boost_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true, true); + solo_boost_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true); HBox* solo_packer = manage (new HBox); solo_packer->set_spacing (12); @@ -151,7 +151,7 @@ MonitorSection::MonitorSection (Session* s) /* Solo (SiP) cut */ - solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, false, false); + solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true); spin_label = manage (new Label (_("SiP Cut"))); spin_packer = manage (new VBox); @@ -234,10 +234,10 @@ MonitorSection::MonitorSection (Session* s) /* Gain */ - gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.781787, 0.01, 0.1, true, 80, 80, false, false); + gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 1.0, 0.1, 1.0, true, 80, 80, false); - spin_label = manage (new Label (_("Gain"))); - spin_packer = manage (new VBox); + spin_label = manage (new Label (_("Monitor"))); + spin_packer = manage (new VBox); spin_packer->show (); spin_packer->set_spacing (6); spin_packer->pack_start (*gain_control, false, false); diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index ffdbdc4e95..33f8a8dc43 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -20,9 +20,12 @@ #include <gtkmm/box.h> #include <gtkmm/alignment.h> #include "gtkmm2ext/utils.h" + #include "ardour/configuration.h" +#include "ardour/rc_configuration.h" #include "ardour/utils.h" #include "ardour/dB.h" + #include "option_editor.h" #include "gui_thread.h" #include "utils.h" @@ -134,8 +137,7 @@ EntryOption::activated () FaderOption::FaderOption (string const & i, string const & n, sigc::slot<gain_t> g, sigc::slot<bool, gain_t> s) : Option (i, n) - // 0.781787 is the value needed for gain to be set to 0. - , _db_adjustment (0.781787, 0, 1, 0.01, 0.1) + , _db_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1) , _get (g) , _set (s) { @@ -166,7 +168,7 @@ void FaderOption::set_state_from_config () { gain_t const val = _get (); - _db_adjustment.set_value (gain_to_slider_position (val)); + _db_adjustment.set_value (gain_to_slider_position_with_max (val, Config->get_max_gain ())); char buf[16]; @@ -182,7 +184,7 @@ FaderOption::set_state_from_config () void FaderOption::db_changed () { - _set (slider_position_to_gain (_db_adjustment.get_value ())); + _set (slider_position_to_gain_with_max (_db_adjustment.get_value (), Config->get_max_gain())); } void diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 3ccb97e5ca..0aeef0ff17 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -300,8 +300,7 @@ ProcessorEntry::name () const SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w) : ProcessorEntry (s, w), _send (s), - /* set the adjustment to a gain of 0dB so that the fader's default value is right */ - _adjustment (0.781787, 0, 1, 0.01, 0.1), + _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1), _fader (_slider, &_adjustment, 0, false), _ignore_gain_change (false) { @@ -326,9 +325,7 @@ SendProcessorEntry::setup_slider_pix () void SendProcessorEntry::show_gain () { - ENSURE_GUI_THREAD (*this, &SendProcessorEntry::show_gain) - - float const value = gain_to_slider_position (_send->amp()->gain ()); + float const value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain()); if (_adjustment.get_value() != value) { _ignore_gain_change = true; @@ -350,7 +347,7 @@ SendProcessorEntry::gain_adjusted () return; } - _send->amp()->set_gain (slider_position_to_gain (_adjustment.get_value()), this); + _send->amp()->set_gain (slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain()), this); } void diff --git a/gtk2_ardour/volume_controller.cc b/gtk2_ardour/volume_controller.cc index 8a382f6cb1..365379933d 100644 --- a/gtk2_ardour/volume_controller.cc +++ b/gtk2_ardour/volume_controller.cc @@ -28,6 +28,7 @@ #include "gtkmm2ext/gui_thread.h" #include "ardour/dB.h" +#include "ardour/rc_configuration.h" #include "ardour/utils.h" #include "volume_controller.h" @@ -42,12 +43,10 @@ VolumeController::VolumeController (Glib::RefPtr<Gdk::Pixbuf> p, bool with_numeric, int subw, int subh, - bool linear, - bool dB) + bool linear) : MotionFeedback (p, MotionFeedback::Rotary, c, def, step, page, "", with_numeric, subw, subh) , _linear (linear) - , _controllable_uses_dB (dB) { set_print_func (VolumeController::_dB_printer, this); @@ -72,27 +71,39 @@ VolumeController::dB_printer (char buf[32], const boost::shared_ptr<PBD::Control if (c) { if (_linear) { - /* controllable units are in dB so just show the value */ + + double val = accurate_coefficient_to_dB (c->get_value()); + if (step_inc < 1.0) { - snprintf (buf, 32, "%.2f dB", c->get_value()); + if (val >= 0.0) { + snprintf (buf, 32, "+%5.2f dB", val); + } else { + snprintf (buf, 32, "%5.2f dB", val); + } } else { - snprintf (buf, 32, "%ld dB", lrint (c->get_value())); + if (val >= 0.0) { + snprintf (buf, 32, "+%2ld dB", lrint (val)); + } else { + snprintf (buf, 32, "%2ld dB", lrint (val)); + } } + } else { - double gain_coefficient; - - if (!_controllable_uses_dB) { - gain_coefficient = c->get_value(); - } else { - double fract = (c->get_value() - c->lower()) / (c->upper() - c->lower()); - gain_coefficient = slider_position_to_gain (fract); - } + double dB = accurate_coefficient_to_dB (c->get_value()); if (step_inc < 1.0) { - snprintf (buf, 32, "%.2f dB", accurate_coefficient_to_dB (gain_coefficient)); + if (dB >= 0.0) { + snprintf (buf, 32, "+%5.2f dB", dB); + } else { + snprintf (buf, 32, "%5.2f dB", dB); + } } else { - snprintf (buf, 32, "%ld dB", lrint (accurate_coefficient_to_dB (gain_coefficient))); + if (dB >= 0.0) { + snprintf (buf, 32, "+%2ld dB", lrint (dB)); + } else { + snprintf (buf, 32, "%2ld dB", lrint (dB)); + } } } } else { @@ -111,8 +122,7 @@ VolumeController::to_control_value (double display_value) if (_linear) { v = _controllable->lower() + ((_controllable->upper() - _controllable->lower()) * display_value); } else { - - v = slider_position_to_gain (display_value); + v = slider_position_to_gain_with_max (display_value, ARDOUR::Config->get_max_gain()); } return v; @@ -123,11 +133,18 @@ VolumeController::to_display_value (double control_value) { double v; - if (_linear) { +// if (_linear) { v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower()); - } else { - v = gain_to_slider_position (control_value); - } +// } else { +// v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain()); +// } return v; } + +double +VolumeController::adjust (double control_delta) +{ + return std::max (_controllable->lower(), std::min (_controllable->upper(), _controllable->get_value() + control_delta)); +} + diff --git a/gtk2_ardour/volume_controller.h b/gtk2_ardour/volume_controller.h index 8693f5f0da..28877b7987 100644 --- a/gtk2_ardour/volume_controller.h +++ b/gtk2_ardour/volume_controller.h @@ -35,8 +35,7 @@ class VolumeController : public Gtkmm2ext::MotionFeedback bool with_numeric = true, int image_width = 40, int image_height = 40, - bool linear = true, - bool dB = false); + bool linear = true); virtual ~VolumeController () {} @@ -45,10 +44,13 @@ class VolumeController : public Gtkmm2ext::MotionFeedback protected: double to_control_value (double); double to_display_value (double); + double adjust (double nominal_delta); + + double display_value () const; + double control_value () const; private: bool _linear; - bool _controllable_uses_dB; void dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj); }; |