Refactor API to allow VST2 plugins to callback to I/O and RegionFx
This commit is contained in:
@@ -95,6 +95,9 @@ public:
|
||||
virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const;
|
||||
virtual void clear_stats ();
|
||||
|
||||
ChanMapping input_map (uint32_t num) const;
|
||||
ChanMapping output_map (uint32_t num) const;
|
||||
|
||||
/* ControlSet */
|
||||
std::shared_ptr<Evoral::Control> control_factory (const Evoral::Parameter& id);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/automation_control.h"
|
||||
#include "ardour/chan_mapping.h"
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/plugin_types.h"
|
||||
|
||||
@@ -68,6 +69,9 @@ public:
|
||||
virtual bool get_stats (PBD::microseconds_t&, PBD::microseconds_t&, double&, double&) const = 0;
|
||||
virtual void clear_stats () = 0;
|
||||
|
||||
virtual ChanMapping input_map (uint32_t num) const = 0;
|
||||
virtual ChanMapping output_map (uint32_t num) const = 0;
|
||||
|
||||
/** A control that manipulates a plugin parameter (control port). */
|
||||
struct PluginControl : public AutomationControl {
|
||||
PluginControl (Session& s,
|
||||
|
||||
@@ -87,12 +87,12 @@ public:
|
||||
virtual void set_insert_id (PBD::ID id) {}
|
||||
virtual void set_state_dir (const std::string& d = "") {}
|
||||
|
||||
void set_insert (PluginInsert* pi, uint32_t num) {
|
||||
_pi = pi;
|
||||
void set_insert (PlugInsertBase* pib, uint32_t num) {
|
||||
_pib = pib;
|
||||
_num = num;
|
||||
}
|
||||
|
||||
PluginInsert* plugin_insert () const { return _pi; }
|
||||
PlugInsertBase* plugin_insert () const { return _pib; }
|
||||
uint32_t plugin_number () const { return _num; }
|
||||
|
||||
virtual std::string unique_id () const = 0;
|
||||
@@ -443,8 +443,8 @@ private:
|
||||
void invalidate_preset_cache (std::string const&, Plugin*, bool);
|
||||
void resolve_midi ();
|
||||
|
||||
PluginInsert* _pi;
|
||||
uint32_t _num;
|
||||
PlugInsertBase* _pib;
|
||||
uint32_t _num;
|
||||
|
||||
PBD::ScopedConnection _preset_connection;
|
||||
};
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/libardour_visibility.h"
|
||||
#include "ardour/chan_mapping.h"
|
||||
#include "ardour/fixed_delay.h"
|
||||
#include "ardour/io.h"
|
||||
#include "ardour/types.h"
|
||||
|
||||
@@ -103,6 +103,22 @@ public:
|
||||
}
|
||||
void clear_stats () {}
|
||||
|
||||
ChanMapping input_map (uint32_t num) const {
|
||||
if (num < _in_map.size()) {
|
||||
return _in_map.find (num)->second;
|
||||
} else {
|
||||
return ChanMapping ();
|
||||
}
|
||||
}
|
||||
|
||||
ChanMapping output_map (uint32_t num) const {
|
||||
if (num < _out_map.size()) {
|
||||
return _out_map.find (num)->second;
|
||||
} else {
|
||||
return ChanMapping ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Stateful */
|
||||
XMLNode& get_state (void) const;
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
||||
@@ -257,6 +257,7 @@ IOPlug::setup ()
|
||||
_plugin->reconfigure_io (_n_in, aux_in, _n_out);
|
||||
_plugin->ParameterChangedExternally.connect_same_thread (*this, boost::bind (&IOPlug::parameter_changed_externally, this, _1, _2));
|
||||
_plugin->activate ();
|
||||
_plugin->set_insert (this, 0);
|
||||
}
|
||||
|
||||
samplecnt_t
|
||||
@@ -436,6 +437,26 @@ IOPlug::ensure_io ()
|
||||
return true;
|
||||
}
|
||||
|
||||
ChanMapping
|
||||
IOPlug::input_map (uint32_t num) const
|
||||
{
|
||||
if (num == 1) {
|
||||
return ChanMapping (_n_in);
|
||||
} else {
|
||||
return ChanMapping ();
|
||||
}
|
||||
}
|
||||
|
||||
ChanMapping
|
||||
IOPlug::output_map (uint32_t num) const
|
||||
{
|
||||
if (num == 1) {
|
||||
return ChanMapping (_n_out);
|
||||
} else {
|
||||
return ChanMapping ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IOPlug::process ()
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ Plugin::Plugin (AudioEngine& e, Session& s)
|
||||
, _parameter_changed_since_last_preset (false)
|
||||
, _immediate_events(6096) // FIXME: size?
|
||||
, _resolve_midi (false)
|
||||
, _pi (0)
|
||||
, _pib (0)
|
||||
, _num (0)
|
||||
{
|
||||
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
||||
@@ -118,7 +118,7 @@ Plugin::Plugin (const Plugin& other)
|
||||
, _parameter_changed_since_last_preset (false)
|
||||
, _immediate_events(6096) // FIXME: size?
|
||||
, _resolve_midi (false)
|
||||
, _pi (other._pi)
|
||||
, _pib (other._pib)
|
||||
, _num (other._num)
|
||||
{
|
||||
_pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
|
||||
|
||||
@@ -222,6 +222,8 @@ RegionFxPlugin::add_plugin (std::shared_ptr<Plugin> plugin)
|
||||
plugin->EndTouch.connect_same_thread (*this, boost::bind (&RegionFxPlugin::end_touch, this, _1));
|
||||
}
|
||||
|
||||
plugin->set_insert (this, _plugins.size ());
|
||||
|
||||
_plugins.push_back (plugin);
|
||||
|
||||
if (_plugins.size () > 1) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/tempo.h"
|
||||
#include "ardour/plugin_insert.h"
|
||||
#include "ardour/plug_insert_base.h"
|
||||
#include "ardour/windows_vst_plugin.h"
|
||||
#include "ardour/vestige/vestige.h"
|
||||
#include "ardour/vst_types.h"
|
||||
@@ -529,7 +529,7 @@ intptr_t Session::vst_callback (
|
||||
SHOW_CALLBACK ("audioMasterBeginEdit");
|
||||
// begin of automation session (when mouse down), parameter index in <index>
|
||||
if (plug && plug->plugin_insert ()) {
|
||||
std::shared_ptr<AutomationControl> ac = plug->plugin_insert ()->automation_control (Evoral::Parameter (PluginAutomation, 0, index));
|
||||
std::shared_ptr<AutomationControl> ac = std::dynamic_pointer_cast<AutomationControl>(plug->plugin_insert ()->control (Evoral::Parameter (PluginAutomation, 0, index)));
|
||||
if (ac) {
|
||||
ac->start_touch (timepos_t (ac->session().transport_sample()));
|
||||
}
|
||||
@@ -540,7 +540,7 @@ intptr_t Session::vst_callback (
|
||||
SHOW_CALLBACK ("audioMasterEndEdit");
|
||||
// end of automation session (when mouse up), parameter index in <index>
|
||||
if (plug && plug->plugin_insert ()) {
|
||||
std::shared_ptr<AutomationControl> ac = plug->plugin_insert ()->automation_control (Evoral::Parameter (PluginAutomation, 0, index));
|
||||
std::shared_ptr<AutomationControl> ac = std::dynamic_pointer_cast<AutomationControl>(plug->plugin_insert ()->control (Evoral::Parameter (PluginAutomation, 0, index)));
|
||||
if (ac) {
|
||||
ac->stop_touch (timepos_t (ac->session().transport_sample()));
|
||||
}
|
||||
|
||||
@@ -460,7 +460,8 @@ VSTPlugin::load_plugin_preset (PresetRecord r)
|
||||
sscanf (r.uri.c_str(), "VST:%d:%d", &id, &index);
|
||||
#endif
|
||||
_state->want_program = index;
|
||||
if (!has_editor () || 0 == plugin_insert ()->window_proxy ()) {
|
||||
PluginInsert* pi = dynamic_cast<PluginInsert*> (plugin_insert ());
|
||||
if (!has_editor () || (!pi || 0 == pi->window_proxy ())) {
|
||||
vststate_maybe_set_program (_state);
|
||||
_state->want_chunk = 0;
|
||||
_state->want_program = -1;
|
||||
@@ -508,7 +509,8 @@ VSTPlugin::load_user_preset (PresetRecord r)
|
||||
_state->wanted_chunk = raw_data;
|
||||
_state->wanted_chunk_size = size;
|
||||
_state->want_chunk = 1;
|
||||
if (!has_editor () || (plugin_insert () && 0 == plugin_insert ()->window_proxy ())) {
|
||||
PluginInsert* pi = dynamic_cast<PluginInsert*> (plugin_insert ());
|
||||
if (!has_editor () || (!pi || 0 == pi->window_proxy ())) {
|
||||
vststate_maybe_set_program (_state);
|
||||
_state->want_chunk = 0;
|
||||
_state->want_program = -1;
|
||||
|
||||
Reference in New Issue
Block a user