here you go


>From fe4bf28f227f62df17a506adc37146c2d7a43246 Mon Sep 17 00:00:00 2001
From: Oli Larkin <[email protected]>
Date: Tue, 26 Aug 2014 17:35:04 +0100
Subject: [PATCH] vstui.h sliders will now set Faust::getParameterDisplay
 display string precision based on the step

---
 architecture/faust/vst/vstui.h | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/architecture/faust/vst/vstui.h b/architecture/faust/vst/vstui.h
index 9ea4ffc..96aa51a 100644
--- a/architecture/faust/vst/vstui.h
+++ b/architecture/faust/vst/vstui.h
@@ -135,6 +135,7 @@ public:
   virtual void  GetDisplay(char *text){(*fZone>0.5f)? std::strcpy(text,"ON"): 
std::strcpy(text,"OFF");}
 };
 
+#define MAX_PARAM_DISPLAY_PRECISION 6
 /*--------------------------------------------------------------------------*/
 class vstSlider : public vstUIObject{
 
@@ -144,17 +145,21 @@ private:
   float fMin;
   float fMax;
   float fStep;
+  int fPrecision;
        
 public:        
        
   vstSlider(const char* label, float* zone, float init, float min, float max, 
float step)
-    :vstUIObject(label,zone), fInit(init), fMin(min), fMax(max),fStep(step) {}
-  virtual ~vstSlider() {}      
+               :vstUIObject(label,zone), fInit(init), fMin(min), fMax(max), 
fStep(step), fPrecision(0) {
+                       for (fPrecision = 0; fPrecision < 
MAX_PARAM_DISPLAY_PRECISION && step != floor(step); ++fPrecision, step *= 10.0) 
{;}
+               }
+               
+               virtual ~vstSlider() {}
 
   // The VST host calls GetValue() and expects a result in [0,1].
   // The VST host calls SetValue(f) with f in [0,1]. We convert to real units.
   // When we process MIDI controls, we call SetValueNoNormalization(f) with f 
in real units.
-  virtual float GetValue() {
+        virtual float GetValue() {
                return (*fZone-fMin)/(fMax-fMin); // normalize
        }
 
@@ -177,6 +182,13 @@ public:
        int getStep() const {
                return fStep;
        }
+       
+       void GetDisplay(char *text) {
+               if(fPrecision == 0)
+                       std::sprintf(text, "%d", int(*fZone));
+               else
+                       std::sprintf(text,"%.*f", fPrecision, *fZone);
+       }
 };
 
 /*--------------------------------------------------------------------------*/
-- 
1.7.11.3



On 26 Aug 2014, at 16:06, Stéphane LETZ wrote:

> Patch is welcome.
> 
> Stéphane 
> 
> Le 26 août 2014 à 12:13, Oli Larkin <[email protected]> a écrit :
> 
>> if I do something like this, I would expect the vst2 parameter returned via 
>> AudioEffectX::getParameterDisplay() to show a resolution of 2 dp, but 
>> instead it shows 6 dp
>> 
>> basepitch = hslider("Base Pitch [unit:semitones]", 60, 24, 96, 0.01);
>> 
>> any chance this could be addressed?
>> 
>> thanks!
>> 
>> oli
>> 
>> 
>> ------------------------------------------------------------------------------
>> Slashdot TV.  
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> Faudiostream-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/faudiostream-users
> 


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Faudiostream-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to