summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-11 02:05:44 +0000
committerDavid Robillard <d@drobilla.net>2008-01-11 02:05:44 +0000
commit822b2d86e56267773153a487fbf02dd8697d222f (patch)
tree8dce7ec1216af9bc9c39da09990bf6b4ea2f8944 /libs
parentcc497040d30315036587e78341005056f3870cf5 (diff)
Code cleanup.
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2892 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/ladspa_plugin.h101
-rw-r--r--libs/ardour/ladspa_plugin.cc78
2 files changed, 85 insertions, 94 deletions
diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h
index 3c795299cc..8c00675b69 100644
--- a/libs/ardour/ardour/ladspa_plugin.h
+++ b/libs/ardour/ardour/ladspa_plugin.h
@@ -53,51 +53,47 @@ class LadspaPlugin : public ARDOUR::Plugin
/* Plugin interface */
std::string unique_id() const;
- const char * label() const { return descriptor->Label; }
- const char * name() const { return descriptor->Name; }
- const char * maker() const { return descriptor->Maker; }
- uint32_t parameter_count() const { return descriptor->PortCount; }
- float default_value (uint32_t port);
- nframes_t latency() const;
- void set_parameter (uint32_t port, float val);
- float get_parameter (uint32_t port) const;
- int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
+ const char* label() const { return _descriptor->Label; }
+ const char* name() const { return _descriptor->Name; }
+ const char* maker() const { return _descriptor->Maker; }
+ uint32_t parameter_count() const { return _descriptor->PortCount; }
+ float default_value (uint32_t port);
+ nframes_t latency() const;
+ void set_parameter (uint32_t port, float val);
+ float get_parameter (uint32_t port) const;
+ int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
+ uint32_t nth_parameter (uint32_t port, bool& ok) const;
+
std::set<uint32_t> automatable() const;
- uint32_t nth_parameter (uint32_t port, bool& ok) const;
- void activate () {
- if (was_activated)
- return;
- if (descriptor->activate) {
- descriptor->activate (handle);
- }
+ void activate () {
+ if (!_was_activated && _descriptor->activate)
+ _descriptor->activate (_handle);
- was_activated = true;
+ _was_activated = true;
}
- void deactivate () {
- if (!was_activated)
- return;
- if (descriptor->deactivate) {
- descriptor->deactivate (handle);
- }
+ void deactivate () {
+ if (_was_activated && _descriptor->deactivate)
+ _descriptor->deactivate (_handle);
- was_activated = false;
+ _was_activated = false;
}
+
void cleanup () {
activate();
deactivate();
- if (descriptor->cleanup) {
- descriptor->cleanup (handle);
- }
+ if (_descriptor->cleanup)
+ _descriptor->cleanup (_handle);
}
+
void set_block_size (nframes_t nframes) {}
- int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, nframes_t nframes, nframes_t offset);
+ int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, nframes_t nframes, nframes_t offset);
string describe_parameter (uint32_t);
string state_node_name() const { return "ladspa"; }
- void print_parameter (uint32_t, char*, uint32_t len) const;
+ void print_parameter (uint32_t, char*, uint32_t len) const;
bool parameter_is_audio(uint32_t) const;
bool parameter_is_control(uint32_t) const;
@@ -106,8 +102,8 @@ class LadspaPlugin : public ARDOUR::Plugin
bool parameter_is_toggled(uint32_t) const;
XMLNode& get_state();
- int set_state(const XMLNode& node);
- bool save_preset(string name);
+ int set_state(const XMLNode& node);
+ bool save_preset(string name);
bool has_editor() const { return false; }
@@ -115,32 +111,27 @@ class LadspaPlugin : public ARDOUR::Plugin
/* LADSPA extras */
- LADSPA_Properties properties() const { return descriptor->Properties; }
- uint32_t index() const { return _index; }
- const char * copyright() const { return descriptor->Copyright; }
- LADSPA_PortDescriptor port_descriptor(uint32_t i) const { return descriptor->PortDescriptors[i]; }
- const LADSPA_PortRangeHint * port_range_hints() const { return descriptor->PortRangeHints; }
- const char * const * port_names() const { return descriptor->PortNames; }
- void set_gain (float gain) {
- descriptor->set_run_adding_gain (handle, gain);
- }
- void run_adding (uint32_t nsamples) {
- descriptor->run_adding (handle, nsamples);
- }
- void connect_port (uint32_t port, float *ptr) {
- descriptor->connect_port (handle, port, ptr);
- }
+ LADSPA_Properties properties() const { return _descriptor->Properties; }
+ uint32_t index() const { return _index; }
+ const char * copyright() const { return _descriptor->Copyright; }
+ LADSPA_PortDescriptor port_descriptor(uint32_t i) const { return _descriptor->PortDescriptors[i]; }
+ const LADSPA_PortRangeHint* port_range_hints() const { return _descriptor->PortRangeHints; }
+ const char * const * port_names() const { return _descriptor->PortNames; }
+
+ void set_gain (float gain) { _descriptor->set_run_adding_gain (_handle, gain); }
+ void run_adding (uint32_t nsamples) { _descriptor->run_adding (_handle, nsamples); }
+ void connect_port (uint32_t port, float *ptr) { _descriptor->connect_port (_handle, port, ptr); }
private:
- void *module;
- const LADSPA_Descriptor *descriptor;
- LADSPA_Handle handle;
- nframes_t sample_rate;
- LADSPA_Data *control_data;
- LADSPA_Data *shadow_data;
- LADSPA_Data *latency_control_port;
- uint32_t _index;
- bool was_activated;
+ void* _module;
+ const LADSPA_Descriptor* _descriptor;
+ LADSPA_Handle _handle;
+ nframes_t _sample_rate;
+ LADSPA_Data* _control_data;
+ LADSPA_Data* _shadow_data;
+ LADSPA_Data* _latency_control_port;
+ uint32_t _index;
+ bool _was_activated;
void init (void *mod, uint32_t index, nframes_t rate);
void run (nframes_t nsamples);
diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc
index 3b32d62dc7..28770699b1 100644
--- a/libs/ardour/ladspa_plugin.cc
+++ b/libs/ardour/ladspa_plugin.cc
@@ -59,11 +59,11 @@ LadspaPlugin::LadspaPlugin (void *mod, AudioEngine& e, Session& session, uint32_
LadspaPlugin::LadspaPlugin (const LadspaPlugin &other)
: Plugin (other)
{
- init (other.module, other._index, other.sample_rate);
+ init (other._module, other._index, other._sample_rate);
for (uint32_t i = 0; i < parameter_count(); ++i) {
- control_data[i] = other.shadow_data[i];
- shadow_data[i] = other.shadow_data[i];
+ _control_data[i] = other._shadow_data[i];
+ _shadow_data[i] = other._shadow_data[i];
}
}
@@ -74,61 +74,61 @@ LadspaPlugin::init (void *mod, uint32_t index, nframes_t rate)
uint32_t i, port_cnt;
const char *errstr;
- module = mod;
- control_data = 0;
- shadow_data = 0;
- latency_control_port = 0;
- was_activated = false;
+ _module = mod;
+ _control_data = 0;
+ _shadow_data = 0;
+ _latency_control_port = 0;
+ _was_activated = false;
- dfunc = (LADSPA_Descriptor_Function) dlsym (module, "ladspa_descriptor");
+ dfunc = (LADSPA_Descriptor_Function) dlsym (_module, "ladspa_descriptor");
if ((errstr = dlerror()) != NULL) {
error << _("LADSPA: module has no descriptor function.") << endmsg;
throw failed_constructor();
}
- if ((descriptor = dfunc (index)) == 0) {
+ if ((_descriptor = dfunc (index)) == 0) {
error << _("LADSPA: plugin has gone away since discovery!") << endmsg;
throw failed_constructor();
}
_index = index;
- if (LADSPA_IS_INPLACE_BROKEN(descriptor->Properties)) {
- error << string_compose(_("LADSPA: \"%1\" cannot be used, since it cannot do inplace processing"), descriptor->Name) << endmsg;
+ if (LADSPA_IS_INPLACE_BROKEN(_descriptor->Properties)) {
+ error << string_compose(_("LADSPA: \"%1\" cannot be used, since it cannot do inplace processing"), _descriptor->Name) << endmsg;
throw failed_constructor();
}
- sample_rate = rate;
+ _sample_rate = rate;
- if (descriptor->instantiate == 0) {
+ if (_descriptor->instantiate == 0) {
throw failed_constructor();
}
- if ((handle = descriptor->instantiate (descriptor, rate)) == 0) {
+ if ((_handle = _descriptor->instantiate (_descriptor, rate)) == 0) {
throw failed_constructor();
}
port_cnt = parameter_count();
- control_data = new LADSPA_Data[port_cnt];
- shadow_data = new LADSPA_Data[port_cnt];
+ _control_data = new LADSPA_Data[port_cnt];
+ _shadow_data = new LADSPA_Data[port_cnt];
for (i = 0; i < port_cnt; ++i) {
if (LADSPA_IS_PORT_CONTROL(port_descriptor (i))) {
- connect_port (i, &control_data[i]);
+ connect_port (i, &_control_data[i]);
if (LADSPA_IS_PORT_OUTPUT(port_descriptor (i)) &&
strcmp (port_names()[i], X_("latency")) == 0) {
- latency_control_port = &control_data[i];
- *latency_control_port = 0;
+ _latency_control_port = &_control_data[i];
+ *_latency_control_port = 0;
}
if (!LADSPA_IS_PORT_INPUT(port_descriptor (i))) {
continue;
}
- shadow_data[i] = default_value (i);
+ _shadow_data[i] = default_value (i);
}
}
@@ -148,12 +148,12 @@ LadspaPlugin::~LadspaPlugin ()
// dlclose (module);
- if (control_data) {
- delete [] control_data;
+ if (_control_data) {
+ delete [] _control_data;
}
- if (shadow_data) {
- delete [] shadow_data;
+ if (_shadow_data) {
+ delete [] _shadow_data;
}
}
@@ -161,7 +161,7 @@ string
LadspaPlugin::unique_id() const
{
char buf[32];
- snprintf (buf, sizeof (buf), "%lu", descriptor->UniqueID);
+ snprintf (buf, sizeof (buf), "%lu", _descriptor->UniqueID);
return string (buf);
}
@@ -281,10 +281,10 @@ LadspaPlugin::default_value (uint32_t port)
if (LADSPA_IS_HINT_SAMPLE_RATE(prh[port].HintDescriptor) && !earlier_hint) {
if (bounds_given) {
if (sr_scaling) {
- ret *= sample_rate;
+ ret *= _sample_rate;
}
} else {
- ret = sample_rate;
+ ret = _sample_rate;
}
}
@@ -294,8 +294,8 @@ LadspaPlugin::default_value (uint32_t port)
void
LadspaPlugin::set_parameter (uint32_t which, float val)
{
- if (which < descriptor->PortCount) {
- shadow_data[which] = (LADSPA_Data) val;
+ if (which < _descriptor->PortCount) {
+ _shadow_data[which] = (LADSPA_Data) val;
ParameterChanged (which, val); /* EMIT SIGNAL */
if (which < parameter_count() && controls[which]) {
@@ -314,9 +314,9 @@ float
LadspaPlugin::get_parameter (uint32_t which) const
{
if (LADSPA_IS_PORT_INPUT(port_descriptor (which))) {
- return (float) shadow_data[which];
+ return (float) _shadow_data[which];
} else {
- return (float) control_data[which];
+ return (float) _control_data[which];
}
}
@@ -327,7 +327,7 @@ LadspaPlugin::nth_parameter (uint32_t n, bool& ok) const
ok = false;
- for (c = 0, x = 0; x < descriptor->PortCount; ++x) {
+ for (c = 0, x = 0; x < _descriptor->PortCount; ++x) {
if (LADSPA_IS_PORT_CONTROL (port_descriptor (x))) {
if (c++ == n) {
ok = true;
@@ -354,7 +354,7 @@ LadspaPlugin::get_state()
child = new XMLNode("port");
snprintf(buf, sizeof(buf), "%u", i);
child->add_property("number", string(buf));
- snprintf(buf, sizeof(buf), "%+f", shadow_data[i]);
+ snprintf(buf, sizeof(buf), "%+f", _shadow_data[i]);
child->add_property("value", string(buf));
root->add_child_nocopy (*child);
@@ -488,8 +488,8 @@ LadspaPlugin::describe_parameter (uint32_t which)
nframes_t
LadspaPlugin::latency () const
{
- if (latency_control_port) {
- return (nframes_t) floor (*latency_control_port);
+ if (_latency_control_port) {
+ return (nframes_t) floor (*_latency_control_port);
} else {
return 0;
}
@@ -588,16 +588,16 @@ LadspaPlugin::run (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))) {
- control_data[i] = shadow_data[i];
+ _control_data[i] = _shadow_data[i];
}
}
- descriptor->run (handle, nframes);
+ _descriptor->run (_handle, nframes);
}
void
LadspaPlugin::latency_compute_run ()
{
- if (!latency_control_port) {
+ if (!_latency_control_port) {
return;
}