X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fvst_plugin.cc;h=8e0053f778239bba3e7aa394ec601e7862a684f9;hb=81bff2edee31ad64693d5be3c06558714ea92722;hp=85bffc2dc883462596ed6222b4e3f3e071f7da0f;hpb=2b5495b920c67a2a3293d1bb29d8890852498f91;p=ardour.git diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 85bffc2dc8..8e0053f778 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -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); } @@ -282,11 +282,6 @@ VSTPlugin::set_state (const XMLNode& node, int version) LocaleGuard lg; int ret = -1; - if (node.name() != state_node_name()) { - error << _("Bad node sent to VSTPlugin::set_state") << endmsg; - return 0; - } - #ifndef NO_PLUGIN_STATE XMLNode* child; @@ -326,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)) { @@ -350,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) { @@ -376,35 +365,35 @@ 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 { /* old style */ - char label[64]; + char label[VestigeMaxLabelLen]; /* some VST plugins expect this buffer to be zero-filled */ memset (label, 0, sizeof (label)); _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; @@ -598,7 +587,7 @@ VSTPlugin::do_remove_preset (string name) string VSTPlugin::describe_parameter (Evoral::Parameter param) { - char name[64]; + char name[VestigeMaxLabelLen]; if (param.id() == UINT32_MAX - 1) { strcpy (name, _("Plugin Enable")); return name; @@ -617,7 +606,7 @@ VSTPlugin::describe_parameter (Evoral::Parameter param) return name; } -framecnt_t +samplecnt_t VSTPlugin::signal_latency () const { if (_user_latency) { @@ -645,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); @@ -661,7 +650,7 @@ VSTPlugin::connect_and_run (BufferSet& bufs, return 0; } - _transport_frame = start; + _transport_sample = start; _transport_speed = speed; ChanCount bufs_count; @@ -886,6 +875,6 @@ VSTPlugin::first_user_preset_index () const string VSTPlugin::presets_file () const { - return string_compose ("vst-%1", unique_id ()); + return string("vst-") + unique_id (); }