X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fvst_plugin.cc;h=800c5a98561f84d141f4f6f492b8ecd8789457c2;hb=5a8bc070cd5ca79a53487f536c6df966ffc8df39;hp=6465344d6eb7b3fafcd16d1435786bf361ad1546;hpb=8af0757b61990767f2a85e68f535a5af9976fd79;p=ardour.git diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 6465344d6e..800c5a9856 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -41,8 +41,6 @@ #include -#include - #include #include #include @@ -54,6 +52,7 @@ #include using namespace ARDOUR; +using namespace PBD; using std::min; using std::max; @@ -80,7 +79,7 @@ VSTPlugin::VSTPlugin (AudioEngine& e, Session& session, FSTHandle* h) _plugin->dispatcher (_plugin, effSetProgram, 0, 0, NULL, 0.0f); - Plugin::setup_midi_controls (); + Plugin::setup_controls (); } VSTPlugin::VSTPlugin (const VSTPlugin &other) @@ -93,18 +92,18 @@ VSTPlugin::VSTPlugin (const VSTPlugin &other) } _plugin = _fst->plugin; - Plugin::setup_midi_controls (); + Plugin::setup_controls (); } VSTPlugin::~VSTPlugin () { deactivate (); - GoingAway (this); /* EMIT SIGNAL */ + GoingAway (); /* EMIT SIGNAL */ fst_close (_fst); } void -VSTPlugin::set_block_size (jack_nframes_t nframes) +VSTPlugin::set_block_size (nframes_t nframes) { deactivate (); _plugin->dispatcher (_plugin, effSetBlockSize, 0, nframes, NULL, 0.0f); @@ -132,13 +131,6 @@ VSTPlugin::set_parameter (uint32_t which, float val) { _plugin->setParameter (_plugin, which, val); ParameterChanged (which, val); /* EMIT SIGNAL */ - - if (session().get_midi_feedback()) { - - if (which < parameter_count() && midi_controls[which]) { - midi_controls[which]->send_feedback (val); - } - } } float @@ -182,23 +174,23 @@ VSTPlugin::get_state() if (stat (path.c_str(), &sbuf)) { if (errno == ENOENT) { - if (mkdir (path.c_str(), 0600)) { - error << compose (_("cannot create VST chunk directory: %1"), - strerror (errno)) + if (g_mkdir_with_parents (path.c_str(), 0600)) { + error << string_compose (_("cannot create VST chunk directory: %1"), + strerror (errno)) << endmsg; return *root; } } else { - error << compose (_("cannot check VST chunk directory: %1"), + error << string_compose (_("cannot check VST chunk directory: %1"), strerror (errno)) << endmsg; return *root; } } else if (!S_ISDIR (sbuf.st_mode)) { - error << compose (_("%1 exists but is not a directory"), path) + error << string_compose (_("%1 exists but is not a directory"), path) << endmsg; return *root; } @@ -220,7 +212,7 @@ VSTPlugin::get_state() char index[64]; char val[32]; snprintf (index, sizeof (index), "param_%ld", n); - snprintf (val, sizeof (val), "%f", _plugin->getParameter (_plugin, n)); + snprintf (val, sizeof (val), "%.12g", _plugin->getParameter (_plugin, n)); parameters->add_property (index, val); } @@ -253,6 +245,7 @@ VSTPlugin::set_state(const XMLNode& node) for (i = child->properties().begin(); i != child->properties().end(); ++i) { long param; float val; + sscanf ((*i)->name().c_str(), "param_%ld", ¶m); sscanf ((*i)->value().c_str(), "%f", &val); @@ -365,7 +358,7 @@ VSTPlugin::describe_parameter (uint32_t param) return name; } -jack_nframes_t +nframes_t VSTPlugin::latency () const { return _plugin->initialDelay; @@ -384,19 +377,19 @@ VSTPlugin::automatable () const } int -VSTPlugin::connect_and_run (vector& bufs, uint32_t maxbuf, int32_t& in_index, int32_t& out_index, jack_nframes_t nframes, jack_nframes_t offset) +VSTPlugin::connect_and_run (vector& bufs, uint32_t maxbuf, int32_t& in_index, int32_t& out_index, nframes_t nframes, nframes_t offset) { float *ins[_plugin->numInputs]; float *outs[_plugin->numOutputs]; int32_t i; for (i = 0; i < (int32_t) _plugin->numInputs; ++i) { - ins[i] = bufs[min((uint32_t) in_index,maxbuf)]; + ins[i] = bufs[min((uint32_t) in_index,maxbuf - 1)] + offset; in_index++; } for (i = 0; i < (int32_t) _plugin->numOutputs; ++i) { - outs[i] = bufs[min((uint32_t) out_index,maxbuf)]; + outs[i] = bufs[min((uint32_t) out_index,maxbuf - 1)] + offset; /* unbelievably, several VST plugins still rely on Cubase behaviour and do not silence the buffer in processReplacing @@ -487,3 +480,33 @@ VSTPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const memmove (buf, first_nonws, strlen (buf) - (first_nonws - buf) + 1); } + +PluginPtr +VSTPluginInfo::load (Session& session) +{ + try { + PluginPtr plugin; + + if (Config->get_use_vst()) { + FSTHandle* handle; + + handle = fst_load(path.c_str()); + + if ( (int)handle == -1) { + error << string_compose(_("VST: cannot load module from \"%1\""), path) << endmsg; + } else { + plugin.reset (new VSTPlugin (session.engine(), session, handle)); + } + } else { + error << _("You asked ardour to not use any VST plugins") << endmsg; + return PluginPtr ((Plugin*) 0); + } + + plugin->set_info(PluginInfoPtr(new VSTPluginInfo(*this))); + return plugin; + } + + catch (failed_constructor &err) { + return PluginPtr ((Plugin*) 0); + } +}