fix more cut-n-paste coding errors
[ardour.git] / libs / ardour / vst_plugin.cc
index bf7637109d34ab3304b4612a7be098a994a14df3..8e0053f778239bba3e7aa394ec601e7862a684f9 100644 (file)
@@ -47,7 +47,7 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
        , _plugin (0)
        , _pi (0)
        , _num (0)
-       , _transport_frame (0)
+       , _transport_sample (0)
        , _transport_speed (0.f)
        , _eff_bypassed (false)
 {
@@ -62,7 +62,7 @@ VSTPlugin::VSTPlugin (const VSTPlugin& other)
        , _pi (other._pi)
        , _num (other._num)
        , _midi_out_buf (other._midi_out_buf)
-       , _transport_frame (0)
+       , _transport_sample (0)
        , _transport_speed (0.f)
        , _parameter_defaults (other._parameter_defaults)
        , _eff_bypassed (other._eff_bypassed)
@@ -79,8 +79,8 @@ void
 VSTPlugin::open_plugin ()
 {
        _plugin = _state->plugin;
-       assert (_plugin->user == this); // should have been set by {mac_vst|fst|lxvst}_instantiate
-       _plugin->user = this;
+       assert (_plugin->ptr1 == this); // should have been set by {mac_vst|fst|lxvst}_instantiate
+       _plugin->ptr1 = this;
        _state->plugin->dispatcher (_plugin, effOpen, 0, 0, 0, 0);
        _state->vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, 0, 0);
 }
@@ -89,7 +89,7 @@ void
 VSTPlugin::init_plugin ()
 {
        /* set rate and blocksize */
-       _plugin->dispatcher (_plugin, effSetSampleRate, 0, 0, NULL, (float) _session.frame_rate());
+       _plugin->dispatcher (_plugin, effSetSampleRate, 0, 0, NULL, (float) _session.sample_rate());
        _plugin->dispatcher (_plugin, effSetBlockSize, 0, _session.get_block_size(), NULL, 0.0f);
 }
 
@@ -321,15 +321,12 @@ VSTPlugin::set_state (const XMLNode& node, int version)
        return ret;
 }
 
-
 int
 VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc) const
 {
        VstParameterProperties prop;
 
        memset (&prop, 0, sizeof (VstParameterProperties));
-       desc.min_unbound = false;
-       desc.max_unbound = false;
        prop.flags = 0;
 
        if (_plugin->dispatcher (_plugin, effGetParameterProperties, which, 0, &prop, 0)) {
@@ -345,25 +342,22 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
                        desc.upper = 1.0;
                }
 
-               if (prop.flags & kVstParameterUsesIntStep) {
+               const float range = desc.upper - desc.lower;
 
+               if (prop.flags & kVstParameterUsesIntStep && prop.stepInteger < range) {
                        desc.step = prop.stepInteger;
                        desc.smallstep = prop.stepInteger;
                        desc.largestep = prop.stepInteger;
-
-               } else if (prop.flags & kVstParameterUsesFloatStep) {
-
+                       desc.integer_step = true;
+                       desc.rangesteps = 1 + ceilf (range / desc.step);
+               } else if (prop.flags & kVstParameterUsesFloatStep && prop.stepFloat < range) {
                        desc.step = prop.stepFloat;
                        desc.smallstep = prop.smallStepFloat;
                        desc.largestep = prop.largeStepFloat;
-
+                       desc.rangesteps = 1 + ceilf (range / desc.step);
                } else {
-
-                       float range = desc.upper - desc.lower;
-
-                       desc.step = range / 100.0f;
-                       desc.smallstep = desc.step / 2.0f;
-                       desc.largestep = desc.step * 10.0f;
+                       desc.smallstep = desc.step = range / 300.0f;
+                       desc.largestep =  range / 30.0f;
                }
 
                if (strlen(prop.label) == 0) {
@@ -371,8 +365,6 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
                }
 
                desc.toggled = prop.flags & kVstParameterIsSwitch;
-               desc.logarithmic = false;
-               desc.sr_dependent = false;
                desc.label = Glib::locale_to_utf8 (prop.label);
 
        } else {
@@ -386,20 +378,22 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
                _plugin->dispatcher (_plugin, effGetParamName, which, 0, label, 0);
 
                desc.label = Glib::locale_to_utf8 (label);
-               desc.integer_step = false;
                desc.lower = 0.0f;
                desc.upper = 1.0f;
-               desc.step = 0.01f;
-               desc.smallstep = 0.005f;
-               desc.largestep = 0.1f;
-               desc.toggled = false;
-               desc.logarithmic = false;
-               desc.sr_dependent = false;
+               desc.smallstep = desc.step = 1.f / 300.f;
+               desc.largestep = 1.f / 30.f;
        }
 
-       desc.normal = get_parameter (which);
+       /* TODO we should really call
+        *   desc.update_steps ()
+        * instead of manually assigning steps. Yet, VST prop is (again)
+        * the odd one out compared to other plugin formats.
+        */
+
        if (_parameter_defaults.find (which) == _parameter_defaults.end ()) {
-               _parameter_defaults[which] = desc.normal;
+               _parameter_defaults[which] = get_parameter (which);
+       } else {
+               desc.normal = _parameter_defaults[which];
        }
 
        return 0;
@@ -612,7 +606,7 @@ VSTPlugin::describe_parameter (Evoral::Parameter param)
        return name;
 }
 
-framecnt_t
+samplecnt_t
 VSTPlugin::signal_latency () const
 {
        if (_user_latency) {
@@ -640,9 +634,9 @@ VSTPlugin::automatable () const
 
 int
 VSTPlugin::connect_and_run (BufferSet& bufs,
-               framepos_t start, framepos_t end, double speed,
+               samplepos_t start, samplepos_t end, double speed,
                ChanMapping in_map, ChanMapping out_map,
-               pframes_t nframes, framecnt_t offset)
+               pframes_t nframes, samplecnt_t offset)
 {
        Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
 
@@ -656,7 +650,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
                return 0;
        }
 
-       _transport_frame = start;
+       _transport_sample = start;
        _transport_speed = speed;
 
        ChanCount bufs_count;