change VolumeController::adjust() to do discrete dB increments+decrements
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 20 Jun 2011 13:58:33 +0000 (13:58 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 20 Jun 2011 13:58:33 +0000 (13:58 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9750 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/monitor_section.cc
gtk2_ardour/volume_controller.cc

index ecd1e5c259b97cb747742ddafb9e80d9ae675acb..4c40a655040a5527ff92072fb6e7920a64e403d3 100644 (file)
@@ -70,7 +70,7 @@ MonitorSection::MonitorSection (Session* s)
 
         /* Dim */
 
-        dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 1.0, true, 30, 30, true);
+        dim_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true);
 
         HBox* dim_packer = manage (new HBox);
         dim_packer->show ();
@@ -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.1, 1.0, true, 30, 30, true);
+        solo_boost_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, 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.1, 1.0, true, 30, 30, true);
+        solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.01, 0.1, true, 30, 30, true);
 
         spin_label = manage (new Label (_("SiP Cut")));
         spin_packer = manage (new VBox);
@@ -234,7 +234,7 @@ MonitorSection::MonitorSection (Session* s)
 
         /* Gain */
 
-        gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 1.0, 0.1, 1.0, true, 80, 80, false);
+        gain_control = new VolumeController (big_knob_pixbuf, boost::shared_ptr<Controllable>(), 1.0, 0.01, 0.1, true, 80, 80, false);
 
         spin_label = manage (new Label (_("Monitor")));
        spin_packer = manage (new VBox);
index 365379933dc29143d6fb8c6f416a661cfbb55e44..7d6a3362deafaecd12a1cd3761a5266ea9e571d3 100644 (file)
@@ -133,11 +133,11 @@ 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_with_max (control_value, ARDOUR::Config->get_max_gain());
-//     }
+       } else {
+               v = gain_to_slider_position_with_max (control_value, ARDOUR::Config->get_max_gain());
+       }
 
        return v;
 }
@@ -145,6 +145,25 @@ VolumeController::to_display_value (double control_value)
 double
 VolumeController::adjust (double control_delta)
 {
-       return std::max (_controllable->lower(), std::min (_controllable->upper(), _controllable->get_value() + control_delta));
-}
+       double v = _controllable->get_value ();
+       double abs_delta = fabs (control_delta);
+
+       /* convert to linear/fractional slider position domain */
+       v = gain_to_slider_position_with_max (v, ARDOUR::Config->get_max_gain());
+       /* adjust in this domain */
+       v += control_delta;
+       /* convert back to gain coefficient domain */
+       v = slider_position_to_gain_with_max (v, ARDOUR::Config->get_max_gain());
 
+       /* now round to some precision in the dB domain */
+       v = accurate_coefficient_to_dB (v);
+
+       if (abs_delta <= 0.01) {
+               v -= fmod (v, 0.05);
+       } else {
+               v -= fmod (v, 0.1);
+       } 
+
+       /* and return it */
+       return dB_to_coefficient (v);
+}