an entire freakin' day working on 1 working function, VolumeController::adjust()...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 21 Jun 2011 01:36:20 +0000 (01:36 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 21 Jun 2011 01:36:20 +0000 (01:36 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9752 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/monitor_section.cc
gtk2_ardour/rc_option_editor.cc
gtk2_ardour/volume_controller.cc
libs/ardour/monitor_processor.cc
libs/ardour/utils.cc

index 4c40a655040a5527ff92072fb6e7920a64e403d3..1475644918ffcbf4673939c5472697bd0d0fbe8f 100644 (file)
@@ -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, true);
+        solo_cut_control = new VolumeController (little_knob_pixbuf, boost::shared_ptr<Controllable>(), 0.0, 0.1, 0.5, true, 30, 30, true);
 
         spin_label = manage (new Label (_("SiP Cut")));
         spin_packer = manage (new VBox);
@@ -973,8 +973,7 @@ MonitorSection::assign_controllables ()
         }
 
         if (_session) {
-                boost::shared_ptr<Controllable> c = _session->solo_cut_control();
-                solo_cut_control->set_controllable (c);
+               solo_cut_control->set_controllable (_session->solo_cut_control());
         } else {
                 solo_cut_control->set_controllable (none);
         }
index a74a0cca7eb5df6740c85b34dcf6798ff295e5a3..72ef75ff4d4f9839b95abbbab5c9d0d8b91d4235 100644 (file)
@@ -1257,7 +1257,7 @@ RCOptionEditor::RCOptionEditor ()
        add_option (_("Solo / mute"),
             new FaderOption (
                     "solo-mute-gain",
-                    _("Solo mute cut (dB)"),
+                    _("Solo-in-place mute cut (dB)"),
                     sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_gain),
                     sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_gain)
                     ));
index ca5b0abaa274bad494bdce9ebcc9b0cbaad191ce..c72a31036a1adac47cc7bc3414aa315e9865ec6b 100644 (file)
@@ -130,7 +130,7 @@ VolumeController::to_display_value (double control_value)
        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());
+               v = gain_to_slider_position_with_max (control_value, _controllable->upper());
        }
 
        return v;
@@ -139,29 +139,92 @@ VolumeController::to_display_value (double control_value)
 double
 VolumeController::adjust (double 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;
-       /* clamp in this domain */
-       v = std::max (0.0, std::min (1.0, v));
-       /* convert back to gain coefficient domain */
-       v = slider_position_to_gain_with_max (v, ARDOUR::Config->get_max_gain());
-       /* clamp in this domain */
-       v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
-
-       /* 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);
+       double v;
+
+       if (!_linear) {
+
+               /* we map back into the linear/fractional slider position,
+                * because this kind of control goes all the way down
+                * to -inf dB, and we want this occur in a reasonable way in
+                * terms of user interaction. if we leave the adjustment in the
+                * gain coefficient domain (or dB domain), the lower end of the
+                * control range (getting close to -inf dB) takes forever.
+                */
+
+               /* convert to linear/fractional slider position domain */
+               v = gain_to_slider_position_with_max (_controllable->get_value (), _controllable->upper());
+               /* increment in this domain */
+               v += control_delta;
+               /* clamp to appropriate range for linear/fractional slider domain */
+               v = std::max (0.0, std::min (1.0, v));
+               /* convert back to gain coefficient domain */
+               v = slider_position_to_gain_with_max (v, _controllable->upper());
+               /* clamp in controller domain */
+               v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
+               /* convert to dB domain */
+               v = accurate_coefficient_to_dB (v);
+               /* round up/down to nearest 0.1dB */
+               if (control_delta > 0.0) {
+                       v = ceil (v * 10.0) / 10.0;
+               } else {
+                       v = floor (v * 10.0) / 10.0;
+               }
+               /* and return it */
+               return dB_to_coefficient (v);
        } else {
-               v -= fmod (v, 0.1);
-       } 
+               double mult;
+
+               if (control_delta < 0.0) {
+                       mult = -1.0;
+               } else {
+                       mult = 1.0;
+               }
+
+               if (fabs (control_delta) < 0.05) {
+                       control_delta = mult * 0.05;
+               } else  {
+                       control_delta = mult * 0.1;
+               }
+
+               v = _controllable->get_value();
+
+               if (v == 0.0) {
+                       /* if we don't special case this, we can't escape from
+                          the -infinity dB black hole.
+                       */
+                       if (control_delta > 0.0) {
+                               v = dB_to_coefficient (-100 + control_delta);
+                       }
+               } else {
+                       static const double dB_minus_200 = dB_to_coefficient (-200.0);
+                       static const double dB_minus_100 = dB_to_coefficient (-100.0);
+                       static const double dB_minus_50 = dB_to_coefficient (-50.0);
+                       static const double dB_minus_20 = dB_to_coefficient (-20.0);
+
+                       if (control_delta < 0 && v < dB_minus_200) {
+                               v = 0.0;
+                       } else {
+
+                               /* non-linear scaling as the dB level gets low 
+                                  so that we can hit -inf and get back out of
+                                  it appropriately.
+                               */
+
+                               if (v < dB_minus_100) {
+                                       control_delta *= 1000.0;
+                               } else if (v < dB_minus_50) {
+                                       control_delta *= 100.0;
+                               } else if (v < dB_minus_20) {
+                                       control_delta *= 10.0;
+                               }
+
+                               v = accurate_coefficient_to_dB (v);
+                               v += control_delta;
+                               v = dB_to_coefficient (v);
+                       }
+               }
+
+               return std::max (_controllable->lower(), std::min (_controllable->upper(), v));
+       }
 
-       /* and return it */
-       return dB_to_coefficient (v);
 }
index 835bfde70faf261d8d00981bbbbd260a934ea94d..d12db38c27d042e117d93932b6e5cf2c4f10e42b 100644 (file)
@@ -36,11 +36,12 @@ MonitorProcessor::MonitorProcessor (Session& s)
         , _mono_ptr (new MPControl<bool> (false, _("monitor mono"), Controllable::Toggle))
         , _dim_level_ptr (new MPControl<volatile gain_t> 
                          /* default is -12dB, range is -20dB to 0dB */
-                          (0.251188635826, _("monitor dim level"), Controllable::Flag (0), 0.100000001490, 1.0))
+                          (dB_to_coefficient(-12.0), _("monitor dim level"), Controllable::Flag (0), 
+                          dB_to_coefficient(-20.0), dB_to_coefficient (0.0)))
         , _solo_boost_level_ptr (new MPControl<volatile gain_t> 
                                 /* default is 0dB, range is 0dB to +20dB */
-                                 (1.0, _("monitor solo boost level"), Controllable::Flag (0), 1.0, 10.0))
-         
+                                 (dB_to_coefficient(0.0), _("monitor solo boost level"), Controllable::Flag (0), 
+                                 dB_to_coefficient(0.0), dB_to_coefficient(10.0)))
         , _dim_all_control (_dim_all_ptr)
         , _cut_all_control (_cut_all_ptr)
         , _mono_control (_mono_ptr)
index 4175322bb6c187b530c6ff238ebf7cd895004f67..e1cd35398b775ec97d48456be0b3e12724e9d7cc 100644 (file)
@@ -674,14 +674,12 @@ how_many_dsp_threads ()
 
 double gain_to_slider_position_with_max (double g, double max_gain)
 {
-       /* max gain is ignored for now */
-        return gain_to_slider_position (g);
+        return gain_to_slider_position (g * 2.0/max_gain);
 }
 
 double slider_position_to_gain_with_max (double g, double max_gain)
 {
-       /* max gain is ignored for now */
-       return slider_position_to_gain (g);
+       return slider_position_to_gain (g * max_gain/2.0);
 }
 
 extern "C" {