LADSPA log parameters default values set appropriately and handle localized decimal...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 1 Oct 2009 16:35:55 +0000 (16:35 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 1 Oct 2009 16:35:55 +0000 (16:35 +0000)
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@5704 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ladspa_plugin.cc
libs/gtkmm2ext/barcontroller.cc

index 6a27b8571a3e38b5b5101f52b10d401511922d21..8d8151905031a63c39fbd849661a2226abb1ce20 100644 (file)
@@ -182,34 +182,44 @@ LadspaPlugin::default_value (uint32_t port)
                        ret = prh[port].LowerBound;
                        bounds_given = true;
                        sr_scaling = true;
-                       earlier_hint = true;
                }
                
                /* FIXME: add support for logarithmic defaults */
                
                else if (LADSPA_IS_HINT_DEFAULT_LOW(prh[port].HintDescriptor)) {
-                       ret = prh[port].LowerBound * 0.75f + prh[port].UpperBound * 0.25f;
+                       if (LADSPA_IS_HINT_LOGARITHMIC(prh[port].HintDescriptor)) {
+                               ret = exp(log(prh[port].LowerBound) * 0.75f + log(prh[port].UpperBound) * 0.25f);
+                       }
+                       else {
+                               ret = prh[port].LowerBound * 0.75f + prh[port].UpperBound * 0.25f;
+                       }
                        bounds_given = true;
                        sr_scaling = true;
-                       earlier_hint = true;
                }
                else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(prh[port].HintDescriptor)) {
-                       ret = prh[port].LowerBound * 0.50f + prh[port].UpperBound * 0.50f;
+                       if (LADSPA_IS_HINT_LOGARITHMIC(prh[port].HintDescriptor)) {
+                               ret = exp(log(prh[port].LowerBound) * 0.5f + log(prh[port].UpperBound) * 0.5f);
+                       }
+                       else {
+                               ret = prh[port].LowerBound * 0.5f + prh[port].UpperBound * 0.5f;
+                       }
                        bounds_given = true;
                        sr_scaling = true;
-                       earlier_hint = true;
                }
                else if (LADSPA_IS_HINT_DEFAULT_HIGH(prh[port].HintDescriptor)) {
-                       ret = prh[port].LowerBound * 0.25f + prh[port].UpperBound * 0.75f;
+                       if (LADSPA_IS_HINT_LOGARITHMIC(prh[port].HintDescriptor)) {
+                               ret = exp(log(prh[port].LowerBound) * 0.25f + log(prh[port].UpperBound) * 0.75f);
+                       }
+                       else {
+                               ret = prh[port].LowerBound * 0.25f + prh[port].UpperBound * 0.75f;
+                       }
                        bounds_given = true;
                        sr_scaling = true;
-                       earlier_hint = true;
                }
                else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(prh[port].HintDescriptor)) {
                        ret = prh[port].UpperBound;
                        bounds_given = true;
                        sr_scaling = true;
-                       earlier_hint = true;
                }
                else if (LADSPA_IS_HINT_DEFAULT_0(prh[port].HintDescriptor)) {
                        ret = 0.0f;
index 1af639ec6cd8f1b4702a60f8956d257cf55d045f..775e6b4a8d2f35316349a94650fb397147db468d 100644 (file)
@@ -109,6 +109,7 @@ BarController::entry_input (double* new_value)
        // extract a double from the string and take its log
        Entry *entry = dynamic_cast<Entry *>(&spinner);
        stringstream stream(entry->get_text());
+       stream.imbue(std::locale(""));
 
        double value;
        stream >> value;
@@ -134,12 +135,33 @@ BarController::entry_output ()
        }
 
        // generate the exponential and turn it into a string
+       // convert to correct locale. 
+       
        stringstream stream;
+       string str;
+       size_t found;
+
+       // Gtk.Entry does not like the thousands separator, so we have to  
+       // remove it after conversion from float to string.
+
+       stream.imbue(std::locale(""));
        stream.precision(spinner.get_digits());
+
        stream << fixed << exp(spinner.get_adjustment()->get_value());
        
+       str=stream.str();
+
+       // find thousands separators, remove them
+       found = str.find(use_facet<numpunct<char> >(std::locale("")).thousands_sep());
+       while(found != str.npos) {
+               str.erase(found,1);
+
+               //find next
+               found = str.find(use_facet<numpunct<char> >(std::locale("")).thousands_sep());
+       }
+
        Entry *entry = dynamic_cast<Entry *>(&spinner);
-       entry->set_text(stream.str());
+       entry->set_text(str);
        
        return true;
 }