X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fvst_plugin.cc;h=c9a214c0be6a69e49de6863f512dc17c949fe11a;hb=6946bdc0830c9f0971d2cd0d54b27e343c54d96a;hp=a395582f8fad08d60e2042014fb791883ddaffd9;hpb=3dc7728038860bda6eb4b0de1f4a3e14ec9e86cc;p=ardour.git diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index a395582f8f..c9a214c0be 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -33,7 +33,7 @@ #include "ardour/filesystem_paths.h" #include "ardour/audio_buffer.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace PBD; @@ -46,8 +46,25 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle) , _plugin (0) , _pi (0) , _num (0) + , _transport_frame (0) + , _transport_speed (0.f) { + memset (&_timeInfo, 0, sizeof(_timeInfo)); +} +VSTPlugin::VSTPlugin (const VSTPlugin& other) + : Plugin (other) + , _handle (other._handle) + , _state (other._state) + , _plugin (other._plugin) + , _pi (other._pi) + , _num (other._num) + , _midi_out_buf (other._midi_out_buf) + , _transport_frame (0) + , _transport_speed (0.f) + , _parameter_defaults (other._parameter_defaults) +{ + memset (&_timeInfo, 0, sizeof(_timeInfo)); } VSTPlugin::~VSTPlugin () @@ -89,9 +106,9 @@ VSTPlugin::set_block_size (pframes_t nframes) } float -VSTPlugin::default_value (uint32_t) +VSTPlugin::default_value (uint32_t which) { - return 0; + return _parameter_defaults[which]; } float @@ -151,8 +168,12 @@ int VSTPlugin::set_chunk (gchar const * data, bool single) { gsize size = 0; + int r = 0; guchar* raw_data = g_base64_decode (data, &size); - int const r = _plugin->dispatcher (_plugin, 24 /* effSetChunk */, single ? 1 : 0, size, raw_data, 0); + { + Glib::Threads::Mutex::Lock lm (_lock); + r = _plugin->dispatcher (_plugin, 24 /* effSetChunk */, single ? 1 : 0, size, raw_data, 0); + } g_free (raw_data); return r; } @@ -160,7 +181,7 @@ VSTPlugin::set_chunk (gchar const * data, bool single) void VSTPlugin::add_state (XMLNode* root) const { - LocaleGuard lg (); + LocaleGuard lg; if (_plugin->flags & 32 /* effFlagsProgramsChunks */) { @@ -197,7 +218,7 @@ VSTPlugin::add_state (XMLNode* root) const int VSTPlugin::set_state (const XMLNode& node, int version) { - LocaleGuard lg (); + LocaleGuard lg; int ret = -1; if (node.name() != state_node_name()) { @@ -321,6 +342,9 @@ VSTPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc) desc.sr_dependent = false; } + desc.normal = get_parameter (which); + _parameter_defaults[which] = desc.normal; + return 0; } @@ -533,10 +557,25 @@ VSTPlugin::automatable () const int VSTPlugin::connect_and_run (BufferSet& bufs, + framepos_t start, framepos_t end, double speed, ChanMapping in_map, ChanMapping out_map, pframes_t nframes, framecnt_t offset) { - Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset); + Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset); + + Glib::Threads::Mutex::Lock lm (_state_lock, Glib::Threads::TRY_LOCK); + if (!lm.locked()) { + /* by convention 'effSetChunk' should not be called while processing + * http://www.reaper.fm/sdk/vst/vst_ext.php + * + * All VSTs don't use in-place, PluginInsert::connect_and_run() + * does clear output buffers, so we can just return. + */ + return 0; + } + + _transport_frame = start; + _transport_speed = speed; ChanCount bufs_count; bufs_count.set(DataType::AUDIO, 1);