#include "ardour/filesystem_paths.h"
#include "ardour/audio_buffer.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace PBD;
, _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 ()
}
float
-VSTPlugin::default_value (uint32_t)
+VSTPlugin::default_value (uint32_t which)
{
- return 0;
+ return _parameter_defaults[which];
}
float
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;
}
void
VSTPlugin::add_state (XMLNode* root) const
{
- LocaleGuard lg ();
+ LocaleGuard lg;
if (_plugin->flags & 32 /* effFlagsProgramsChunks */) {
int
VSTPlugin::set_state (const XMLNode& node, int version)
{
- LocaleGuard lg ();
+ LocaleGuard lg;
int ret = -1;
if (node.name() != state_node_name()) {
desc.sr_dependent = false;
}
+ desc.normal = get_parameter (which);
+ _parameter_defaults[which] = desc.normal;
+
return 0;
}
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);