*/
+#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>
+
#include <vector>
#include <string>
#include <pbd/compose.h>
#include <pbd/error.h>
-#include <pbd/pathscanner.h>
#include <pbd/xml++.h>
#include <midi++/manager.h>
#include <ardour/session.h>
#include <ardour/audioengine.h>
#include <ardour/ladspa_plugin.h>
+#include <ardour/buffer_set.h>
#include <pbd/stl_delete.h>
}
}
- Plugin::setup_controls ();
-
latency_compute_run ();
}
}
}
+void
+LadspaPlugin::store_state (PluginState& state)
+{
+ state.parameters.clear ();
+
+ for (uint32_t i = 0; i < parameter_count(); ++i){
+
+ if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) &&
+ LADSPA_IS_PORT_CONTROL(port_descriptor (i))){
+ pair<uint32_t,float> datum;
+
+ datum.first = i;
+ datum.second = shadow_data[i];
+
+ state.parameters.insert (datum);
+ }
+ }
+}
+
+void
+LadspaPlugin::restore_state (PluginState& state)
+{
+ for (map<uint32_t,float>::iterator i = state.parameters.begin(); i != state.parameters.end(); ++i) {
+ set_parameter (i->first, i->second);
+ }
+}
+
float
LadspaPlugin::default_value (uint32_t port)
{
{
if (which < descriptor->PortCount) {
shadow_data[which] = (LADSPA_Data) val;
- ParameterChanged (which, val); /* EMIT SIGNAL */
+#if 0
+ ParameterChanged (Parameter(PluginAutomation, which), val); /* EMIT SIGNAL */
if (which < parameter_count() && controls[which]) {
controls[which]->Changed ();
}
+#endif
} else {
warning << string_compose (_("illegal parameter number used with plugin \"%1\". This may"
return 0;
}
-
string
-LadspaPlugin::describe_parameter (uint32_t which)
+LadspaPlugin::describe_parameter (Parameter which)
{
- if (which < parameter_count()) {
- return port_names()[which];
+ if (which.type() == PluginAutomation && which.id() < parameter_count()) {
+ return port_names()[which.id()];
} else {
return "??";
}
}
-nframes_t
-LadspaPlugin::latency () const
+ARDOUR::nframes_t
+LadspaPlugin::signal_latency () const
{
+ if (_user_latency) {
+ return _user_latency;
+ }
+
if (latency_control_port) {
return (nframes_t) floor (*latency_control_port);
} else {
}
}
-set<uint32_t>
+set<Parameter>
LadspaPlugin::automatable () const
{
- set<uint32_t> ret;
+ set<Parameter> ret;
for (uint32_t i = 0; i < parameter_count(); ++i){
if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) &&
LADSPA_IS_PORT_CONTROL(port_descriptor (i))){
- ret.insert (ret.end(), i);
+ ret.insert (ret.end(), Parameter(PluginAutomation, i));
}
}
}
int
-LadspaPlugin::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, int32_t& in_index, int32_t& out_index, nframes_t nframes, nframes_t offset)
+LadspaPlugin::connect_and_run (BufferSet& bufs, uint32_t& in_index, uint32_t& out_index, nframes_t nframes, nframes_t offset)
{
- uint32_t port_index;
+ uint32_t port_index = 0;
cycles_t then, now;
- port_index = 0;
-
then = get_cycles ();
+ const uint32_t nbufs = bufs.count().n_audio();
+
while (port_index < parameter_count()) {
if (LADSPA_IS_PORT_AUDIO (port_descriptor(port_index))) {
if (LADSPA_IS_PORT_INPUT (port_descriptor(port_index))) {
- connect_port (port_index, bufs[min((uint32_t) in_index,nbufs - 1)] + offset);
+ const size_t index = min(in_index, nbufs - 1);
+ connect_port (port_index, bufs.get_audio(index).data(nframes, offset));
//cerr << this << ' ' << name() << " @ " << offset << " inport " << in_index << " = buf "
// << min((uint32_t)in_index,nbufs) << " = " << &bufs[min((uint32_t)in_index,nbufs)][offset] << endl;
in_index++;
} else if (LADSPA_IS_PORT_OUTPUT (port_descriptor (port_index))) {
- connect_port (port_index, bufs[min((uint32_t) out_index,nbufs - 1)] + offset);
+ const size_t index = min(out_index,nbufs - 1);
+ connect_port (port_index, bufs.get_audio(index).data(nframes, offset));
// cerr << this << ' ' << name() << " @ " << offset << " outport " << out_index << " = buf "
// << min((uint32_t)out_index,nbufs) << " = " << &bufs[min((uint32_t)out_index,nbufs)][offset] << endl;
out_index++;
port_index++;
}
- run (nframes);
+ run_in_place (nframes);
now = get_cycles ();
set_cycles ((uint32_t) (now - then));
}
void
-LadspaPlugin::run (nframes_t nframes)
+LadspaPlugin::run_in_place (nframes_t nframes)
{
for (uint32_t i = 0; i < parameter_count(); ++i) {
if (LADSPA_IS_PORT_INPUT(port_descriptor (i)) && LADSPA_IS_PORT_CONTROL(port_descriptor (i))) {
port_index++;
}
- run (bufsize);
+ run_in_place (bufsize);
deactivate ();
}