#include <ardour/port.h>
#include <ardour/route.h>
#include <ardour/ladspa_plugin.h>
+
+#ifdef VST_SUPPORT
#include <ardour/vst_plugin.h>
+#endif
+
+#ifdef HAVE_AUDIOUNITS
+#include <ardour/audio_unit.h>
+#endif
+
#include <ardour/audioengine.h>
#include <ardour/session.h>
+#include <ardour/types.h>
#include "i18n.h"
{
}
-
Insert::Insert(Session& s, Placement p, int imin, int imax, int omin, int omax)
: Redirect (s, s.next_insert_name(), p, imin, imax, omin, omax)
{
init ();
- save_state (_("initial state"));
-
{
Glib::Mutex::Lock em (_session.engine().process_lock());
IO::MoreOutputs (output_streams ());
set_automatable ();
- save_state (_("initial state"));
-
_plugins[0]->ParameterChanged.connect (mem_fun (*this, &PluginInsert::parameter_changed));
{
init ();
- save_state (_("initial state"));
-
RedirectCreated (this); /* EMIT SIGNAL */
}
PluginInsert::~PluginInsert ()
{
- GoingAway (this); /* EMIT SIGNAL */
+ GoingAway (); /* EMIT SIGNAL */
}
void
uint32_t
PluginInsert::output_streams() const
{
- return _plugins[0]->get_info().n_outputs * _plugins.size();
+ return _plugins[0]->get_info()->n_outputs * _plugins.size();
}
uint32_t
PluginInsert::input_streams() const
{
- return _plugins[0]->get_info().n_inputs * _plugins.size();
+ return _plugins[0]->get_info()->n_inputs * _plugins.size();
}
uint32_t
PluginInsert::natural_output_streams() const
{
- return _plugins[0]->get_info().n_outputs;
+ return _plugins[0]->get_info()->n_outputs;
}
uint32_t
PluginInsert::natural_input_streams() const
{
- return _plugins[0]->get_info().n_inputs;
+ return _plugins[0]->get_info()->n_inputs;
}
bool
a specific "instrument" flag, for example.
*/
- return _plugins[0]->get_info().n_inputs == 0;
+ return _plugins[0]->get_info()->n_inputs == 0;
}
void
}
void
-PluginInsert::set_block_size (jack_nframes_t nframes)
+PluginInsert::set_block_size (nframes_t nframes)
{
for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
(*i)->set_block_size (nframes);
}
void
-PluginInsert::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset, bool with_auto, jack_nframes_t now)
+PluginInsert::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset, bool with_auto, nframes_t now)
{
int32_t in_index = 0;
int32_t out_index = 0;
}
void
-PluginInsert::automation_snapshot (jack_nframes_t now)
+PluginInsert::automation_snapshot (nframes_t now)
{
map<uint32_t,AutomationList*>::iterator li;
}
void
-PluginInsert::transport_stopped (jack_nframes_t now)
+PluginInsert::transport_stopped (nframes_t now)
{
map<uint32_t,AutomationList*>::iterator li;
}
void
-PluginInsert::silence (jack_nframes_t nframes, jack_nframes_t offset)
+PluginInsert::silence (nframes_t nframes, nframes_t offset)
{
int32_t in_index = 0;
int32_t out_index = 0;
if (active()) {
for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
- n = (*i) -> get_info().n_inputs;
+ n = (*i) -> get_info()->n_inputs;
(*i)->connect_and_run (_session.get_silent_buffers (n), n, in_index, out_index, nframes, offset);
}
}
}
void
-PluginInsert::run (vector<Sample *>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset)
+PluginInsert::run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset)
{
if (active()) {
connect_and_run (bufs, nbufs, nframes, offset, false);
}
} else {
- uint32_t in = _plugins[0]->get_info().n_inputs;
- uint32_t out = _plugins[0]->get_info().n_outputs;
+ uint32_t in = _plugins[0]->get_info()->n_inputs;
+ uint32_t out = _plugins[0]->get_info()->n_outputs;
if (out > in) {
}
void
-PluginInsert::automation_run (vector<Sample *>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset)
+PluginInsert::automation_run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset)
{
ControlEvent next_event (0, 0.0f);
- jack_nframes_t now = _session.transport_frame ();
- jack_nframes_t end = now + nframes;
+ nframes_t now = _session.transport_frame ();
+ nframes_t end = now + nframes;
Glib::Mutex::Lock lm (_automation_lock, Glib::TRY_LOCK);
while (nframes) {
- jack_nframes_t cnt = min (((jack_nframes_t) floor (next_event.when) - now), nframes);
+ nframes_t cnt = min (((nframes_t) floor (next_event.when) - now), nframes);
connect_and_run (bufs, nbufs, cnt, offset, true, now);
if (s != al.automation_state()) {
al.set_automation_state (s);
- last_automation_snapshot = 0;
_session.set_dirty ();
}
}
#ifdef VST_SUPPORT
boost::shared_ptr<VSTPlugin> vp;
#endif
+#ifdef HAVE_AUDIOUNITS
+ boost::shared_ptr<AUPlugin> ap;
+#endif
if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
return boost::shared_ptr<Plugin> (new LadspaPlugin (*lp));
#ifdef VST_SUPPORT
} else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
return boost::shared_ptr<Plugin> (new VSTPlugin (*vp));
+#endif
+#ifdef HAVE_AUDIOUNITS
+ } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
+ return boost::shared_ptr<Plugin> (new AUPlugin (*ap));
#endif
}
int32_t
PluginInsert::compute_output_streams (int32_t cnt) const
{
- return _plugins[0]->get_info().n_outputs * cnt;
+ return _plugins[0]->get_info()->n_outputs * cnt;
}
int32_t
int32_t
PluginInsert::can_support_input_configuration (int32_t in) const
{
- int32_t outputs = _plugins[0]->get_info().n_outputs;
- int32_t inputs = _plugins[0]->get_info().n_inputs;
+ int32_t outputs = _plugins[0]->get_info()->n_outputs;
+ int32_t inputs = _plugins[0]->get_info()->n_inputs;
if (inputs == 0) {
node->add_property("id", string(buf));
if (_plugins[0]->state_node_name() == "ladspa") {
char buf[32];
- snprintf (buf, sizeof (buf), "%ld", _plugins[0]->get_info().unique_id);
+ snprintf (buf, sizeof (buf), "%ld", _plugins[0]->get_info()->unique_id);
node->add_property("unique-id", string(buf));
}
node->add_property("count", string_compose("%1", _plugins.size()));
XMLNode* child = new XMLNode("port");
snprintf(buf, sizeof(buf), "%" PRIu32, *x);
child->add_property("number", string(buf));
-
- if (full) {
- snprintf(buf, sizeof(buf), "0x%x", automation_list (*x).automation_state ());
- } else {
- snprintf(buf, sizeof(buf), "0x%x", ARDOUR::Off);
- }
- child->add_property("auto", string(buf));
-
+
+ child->add_child_nocopy (automation_list (*x).state (full));
autonode->add_child_nocopy (*child);
}
XMLPropertyList plist;
const XMLProperty *prop;
long unique = 0;
- PluginInfo::Type type;
+ ARDOUR::PluginType type;
if ((prop = node.property ("type")) == 0) {
error << _("XML node describing insert is missing the `type' field") << endmsg;
}
if (prop->value() == X_("ladspa") || prop->value() == X_("Ladspa")) { /* handle old school sessions */
- type = PluginInfo::LADSPA;
+ type = ARDOUR::LADSPA;
} else if (prop->value() == X_("vst")) {
- type = PluginInfo::VST;
+ type = ARDOUR::VST;
} else {
error << string_compose (_("unknown plugin type %1 in plugin insert state"),
prop->value())
/* look for port automation node */
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- if ((*niter)->name() == port_automation_node_name) {
- XMLNodeList cnodes;
- XMLProperty *cprop;
- XMLNodeConstIterator iter;
- XMLNode *child;
- const char *port;
- uint32_t port_id;
-
- cnodes = (*niter)->children ("port");
-
- for(iter = cnodes.begin(); iter != cnodes.end(); ++iter){
-
- child = *iter;
-
- if ((cprop = child->property("number")) != 0) {
- port = cprop->value().c_str();
- } else {
- warning << _("PluginInsert: Auto: no ladspa port number") << endmsg;
- continue;
- }
- sscanf (port, "%" PRIu32, &port_id);
+ if ((*niter)->name() != port_automation_node_name) {
+ continue;
+ }
- if (port_id >= _plugins[0]->parameter_count()) {
- warning << _("PluginInsert: Auto: port id out of range") << endmsg;
- continue;
- }
-
+ XMLNodeList cnodes;
+ XMLProperty *cprop;
+ XMLNodeConstIterator iter;
+ XMLNode *child;
+ const char *port;
+ uint32_t port_id;
+
+ cnodes = (*niter)->children ("port");
+
+ for(iter = cnodes.begin(); iter != cnodes.end(); ++iter){
+
+ child = *iter;
+
+ if ((cprop = child->property("number")) != 0) {
+ port = cprop->value().c_str();
+ } else {
+ warning << _("PluginInsert: Auto: no ladspa port number") << endmsg;
+ continue;
+ }
+
+ sscanf (port, "%" PRIu32, &port_id);
+
+ if (port_id >= _plugins[0]->parameter_count()) {
+ warning << _("PluginInsert: Auto: port id out of range") << endmsg;
+ continue;
+ }
+
+ if (!child->children().empty()) {
+ automation_list (port_id).set_state (*child->children().front());
+ } else {
if ((cprop = child->property("auto")) != 0) {
+
+ /* old school */
+
int x;
sscanf (cprop->value().c_str(), "0x%x", &x);
automation_list (port_id).set_automation_state (AutoState (x));
+
+ } else {
+
+ /* missing */
+
+ automation_list (port_id).set_automation_state (Off);
}
}
-
- break;
+
}
+
+ /* done */
+
+ break;
}
if (niter == nlist.end()) {
}
// The name of the PluginInsert comes from the plugin, nothing else
- set_name(plugin->get_info().name,this);
+ set_name(plugin->get_info()->name,this);
return 0;
}
return _plugins[0]->describe_parameter (what);
}
-jack_nframes_t
+nframes_t
PluginInsert::latency()
{
return _plugins[0]->latency ();
}
-void
-PluginInsert::store_state (PluginInsertState& state) const
-{
- Redirect::store_state (state);
- _plugins[0]->store_state (state.plugin_state);
-}
-
-Change
-PluginInsert::restore_state (StateManager::State& state)
-{
- PluginInsertState* pistate = dynamic_cast<PluginInsertState*> (&state);
-
- Redirect::restore_state (state);
-
- _plugins[0]->restore_state (pistate->plugin_state);
-
- return Change (0);
-}
-
-StateManager::State*
-PluginInsert::state_factory (std::string why) const
+ARDOUR::PluginType
+PluginInsert::type ()
{
- PluginInsertState* state = new PluginInsertState (why);
-
- store_state (*state);
+ boost::shared_ptr<LadspaPlugin> lp;
+#ifdef VST_SUPPORT
+ boost::shared_ptr<VSTPlugin> vp;
+#endif
+#ifdef HAVE_AUDIOUNITS
+ boost::shared_ptr<AUPlugin> ap;
+#endif
+
+ PluginPtr other = plugin ();
- return state;
+ if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
+ return ARDOUR::LADSPA;
+#ifdef VST_SUPPORT
+ } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
+ return ARDOUR::VST;
+#endif
+#ifdef HAVE_AUDIOUNITS
+ } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
+ return ARDOUR::AudioUnit;
+#endif
+ } else {
+ /* NOT REACHED */
+ return (ARDOUR::PluginType) 0;
+ }
}
/***************************************************************
: Insert (s, p, 1, -1, 1, -1)
{
init ();
- save_state (_("initial state"));
RedirectCreated (this); /* EMIT SIGNAL */
+
}
PortInsert::PortInsert (const PortInsert& other)
: Insert (other._session, other.placement(), 1, -1, 1, -1)
{
init ();
- save_state (_("initial state"));
RedirectCreated (this); /* EMIT SIGNAL */
}
PortInsert::~PortInsert ()
{
- GoingAway (this);
+ GoingAway ();
}
void
-PortInsert::run (vector<Sample *>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset)
+PortInsert::run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset)
{
if (n_outputs() == 0) {
return;
return 0;
}
-jack_nframes_t
+nframes_t
PortInsert::latency()
{
/* because we deliver and collect within the same cycle,
{
return n_outputs ();
}
+