mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-08 15:54:57 +01:00
Consolidate plugin API to access parent insert
Previously this was special cased only for VST for callbacks from the plugin (e.g. check pin connections), but it is generally useful.
This commit is contained in:
parent
05df62ed79
commit
652f99260b
6 changed files with 24 additions and 16 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
#define __ardour_plugin_h__
|
#define __ardour_plugin_h__
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
@ -83,6 +84,14 @@ public:
|
||||||
virtual void set_insert_id (PBD::ID id) {}
|
virtual void set_insert_id (PBD::ID id) {}
|
||||||
virtual void set_state_dir (const std::string& d = "") {}
|
virtual void set_state_dir (const std::string& d = "") {}
|
||||||
|
|
||||||
|
void set_insert (PluginInsert* pi, uint32_t num) {
|
||||||
|
_pi = pi;
|
||||||
|
_num = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginInsert* plugin_insert () const { return _pi; }
|
||||||
|
uint32_t plugin_number () const { return _num; }
|
||||||
|
|
||||||
virtual std::string unique_id () const = 0;
|
virtual std::string unique_id () const = 0;
|
||||||
virtual const char* label () const = 0;
|
virtual const char* label () const = 0;
|
||||||
virtual const char* name () const = 0;
|
virtual const char* name () const = 0;
|
||||||
|
|
@ -410,6 +419,9 @@ private:
|
||||||
|
|
||||||
void invalidate_preset_cache (std::string const&, Plugin*, bool);
|
void invalidate_preset_cache (std::string const&, Plugin*, bool);
|
||||||
void resolve_midi ();
|
void resolve_midi ();
|
||||||
|
|
||||||
|
PluginInsert* _pi;
|
||||||
|
uint32_t _num;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PluginPreset {
|
struct PluginPreset {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/weak_ptr.hpp>
|
#include <boost/weak_ptr.hpp>
|
||||||
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
|
||||||
#include "pbd/stack_allocator.h"
|
#include "pbd/stack_allocator.h"
|
||||||
#include "pbd/timing.h"
|
#include "pbd/timing.h"
|
||||||
|
|
@ -56,7 +57,7 @@ class Plugin;
|
||||||
|
|
||||||
/** Plugin inserts: send data through a plugin
|
/** Plugin inserts: send data through a plugin
|
||||||
*/
|
*/
|
||||||
class LIBARDOUR_API PluginInsert : public Processor
|
class LIBARDOUR_API PluginInsert : public Processor, public boost::enable_shared_from_this <PluginInsert>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PluginInsert (Session&, Temporal::TimeDomain td, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>());
|
PluginInsert (Session&, Temporal::TimeDomain td, boost::shared_ptr<Plugin> = boost::shared_ptr<Plugin>());
|
||||||
|
|
@ -64,6 +65,10 @@ public:
|
||||||
|
|
||||||
void drop_references ();
|
void drop_references ();
|
||||||
|
|
||||||
|
boost::weak_ptr<PluginInsert> weak_ptr () {
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
static const std::string port_automation_node_name;
|
static const std::string port_automation_node_name;
|
||||||
|
|
||||||
int set_state(const XMLNode&, int version);
|
int set_state(const XMLNode&, int version);
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,6 @@ public:
|
||||||
|
|
||||||
int first_user_preset_index () const;
|
int first_user_preset_index () const;
|
||||||
|
|
||||||
void set_insert (PluginInsert* pi, uint32_t num) { _pi = pi; _num = num; }
|
|
||||||
PluginInsert* plugin_insert () const { return _pi; }
|
|
||||||
uint32_t plugin_number () const { return _num; }
|
|
||||||
VstTimeInfo* timeinfo () { return &_timeInfo; }
|
VstTimeInfo* timeinfo () { return &_timeInfo; }
|
||||||
samplepos_t transport_sample () const { return _transport_sample; }
|
samplepos_t transport_sample () const { return _transport_sample; }
|
||||||
float transport_speed () const { return _transport_speed; }
|
float transport_speed () const { return _transport_speed; }
|
||||||
|
|
@ -125,8 +122,6 @@ protected:
|
||||||
VSTHandle* _handle;
|
VSTHandle* _handle;
|
||||||
VSTState* _state;
|
VSTState* _state;
|
||||||
AEffect* _plugin;
|
AEffect* _plugin;
|
||||||
PluginInsert* _pi;
|
|
||||||
uint32_t _num;
|
|
||||||
|
|
||||||
MidiBuffer* _midi_out_buf;
|
MidiBuffer* _midi_out_buf;
|
||||||
VstTimeInfo _timeInfo;
|
VstTimeInfo _timeInfo;
|
||||||
|
|
|
||||||
|
|
@ -95,6 +95,8 @@ Plugin::Plugin (AudioEngine& e, Session& s)
|
||||||
, _have_pending_stop_events (false)
|
, _have_pending_stop_events (false)
|
||||||
, _parameter_changed_since_last_preset (false)
|
, _parameter_changed_since_last_preset (false)
|
||||||
, _immediate_events(6096) // FIXME: size?
|
, _immediate_events(6096) // FIXME: size?
|
||||||
|
, _pi (0)
|
||||||
|
, _num (0)
|
||||||
{
|
{
|
||||||
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
||||||
PresetsChanged.connect_same_thread(_preset_connection, boost::bind (&Plugin::invalidate_preset_cache, this, _1, _2, _3));
|
PresetsChanged.connect_same_thread(_preset_connection, boost::bind (&Plugin::invalidate_preset_cache, this, _1, _2, _3));
|
||||||
|
|
@ -114,6 +116,8 @@ Plugin::Plugin (const Plugin& other)
|
||||||
, _last_preset (other._last_preset)
|
, _last_preset (other._last_preset)
|
||||||
, _parameter_changed_since_last_preset (false)
|
, _parameter_changed_since_last_preset (false)
|
||||||
, _immediate_events(6096) // FIXME: size?
|
, _immediate_events(6096) // FIXME: size?
|
||||||
|
, _pi (other._pi)
|
||||||
|
, _num (other._num)
|
||||||
{
|
{
|
||||||
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3243,12 +3243,8 @@ PluginInsert::add_plugin (boost::shared_ptr<Plugin> plugin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if (defined WINDOWS_VST_SUPPORT || defined LXVST_SUPPORT || defined MACVST_SUPPORT)
|
|
||||||
boost::shared_ptr<VSTPlugin> vst = boost::dynamic_pointer_cast<VSTPlugin> (plugin);
|
plugin->set_insert (this, _plugins.size ());
|
||||||
if (vst) {
|
|
||||||
vst->set_insert (this, _plugins.size ());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_plugins.push_back (plugin);
|
_plugins.push_back (plugin);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,6 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
|
||||||
, _handle (handle)
|
, _handle (handle)
|
||||||
, _state (0)
|
, _state (0)
|
||||||
, _plugin (0)
|
, _plugin (0)
|
||||||
, _pi (0)
|
|
||||||
, _num (0)
|
|
||||||
, _transport_sample (0)
|
, _transport_sample (0)
|
||||||
, _transport_speed (0.f)
|
, _transport_speed (0.f)
|
||||||
, _eff_bypassed (false)
|
, _eff_bypassed (false)
|
||||||
|
|
@ -66,8 +64,6 @@ VSTPlugin::VSTPlugin (const VSTPlugin& other)
|
||||||
, _handle (other._handle)
|
, _handle (other._handle)
|
||||||
, _state (other._state)
|
, _state (other._state)
|
||||||
, _plugin (other._plugin)
|
, _plugin (other._plugin)
|
||||||
, _pi (other._pi)
|
|
||||||
, _num (other._num)
|
|
||||||
, _midi_out_buf (other._midi_out_buf)
|
, _midi_out_buf (other._midi_out_buf)
|
||||||
, _transport_sample (0)
|
, _transport_sample (0)
|
||||||
, _transport_speed (0.f)
|
, _transport_speed (0.f)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue