21 #include "libardour-config.h"
64 init (module_path, index, rate);
93 error <<
_(
"LADSPA: Unable to open module: ") << Glib::Module::get_last_error() <<
endmsg;
98 if (!
_module->get_symbol(
"ladspa_descriptor", func)) {
99 error <<
_(
"LADSPA: module has no descriptor function.") <<
endmsg;
106 error <<
_(
"LADSPA: plugin has gone away since discovery!") <<
endmsg;
134 for (i = 0; i < port_cnt; ++i) {
180 bool bounds_given =
false;
181 bool sr_scaling =
false;
182 bool earlier_hint =
false;
239 if (prh[port].LowerBound < 0) {
253 if (prh[port].UpperBound > 0) {
267 if (prh[port].LowerBound < 0 && prh[port].UpperBound > 0) {
269 }
else if (prh[port].LowerBound < 0 && prh[port].UpperBound < 0) {
296 if (which < _descriptor->PortCount) {
306 controls[which]->Changed ();
312 "indicate a change in the plugin design, and presets may be "
362 snprintf(buf,
sizeof(buf),
"%u", i);
374 if (version < 3000) {
378 #ifndef NO_PLUGIN_STATE
390 error <<
_(
"Bad node sent to LadspaPlugin::set_state") <<
endmsg;
394 #ifndef NO_PLUGIN_STATE
398 for (iter = nodes.begin(); iter != nodes.end(); ++iter) {
402 if ((prop = child->
property(
"number")) != 0) {
403 port = prop->
value().c_str();
408 if ((prop = child->
property(
"value")) != 0) {
409 data = prop->
value().c_str();
415 sscanf (port,
"%" PRIu32, &port_id);
428 #ifndef NO_PLUGIN_STATE
440 error <<
_(
"Bad node sent to LadspaPlugin::set_state") <<
endmsg;
444 #ifndef NO_PLUGIN_STATE
447 for(iter = nodes.begin(); iter != nodes.end(); ++iter){
451 if ((prop = child->
property(
"number")) != 0) {
452 port = prop->
value().c_str();
457 if ((prop = child->
property(
"value")) != 0) {
458 data = prop->
value().c_str();
464 sscanf (port,
"%" PRIu32, &port_id);
554 set<Evoral::Parameter>
557 set<Evoral::Parameter> ret;
583 uint32_t audio_in_index = 0;
584 uint32_t audio_out_index = 0;
586 for (uint32_t port_index = 0; port_index <
parameter_count(); ++port_index) {
651 lrdf_defaults* points = lrdf_get_scale_values(
id, port_index);
659 for (uint32_t i = 0; i < points->count; ++i) {
660 ret->insert(make_pair(points->items[i].label,
661 points->items[i].value));
664 lrdf_free_setting_values(points);
696 uint32_t port_index = 0;
697 uint32_t in_index = 0;
698 uint32_t out_index = 0;
754 if (!isdigit (unique[0])) {
758 id =
atol (unique.c_str());
760 lrdf_uris* set_uris = lrdf_get_setting_uris(
id);
763 for (uint32_t i = 0; i < (uint32_t) set_uris->count; ++i) {
764 if (
char*
label = lrdf_get_label(set_uris->items[i])) {
766 _presets.insert (make_pair (set_uris->items[i], rec));
769 lrdf_free_uris(set_uris);
779 lrdf_defaults* defs = lrdf_get_setting_values (r.
uri.c_str());
782 for (uint32_t i = 0; i < (uint32_t) defs->count; ++i) {
787 lrdf_free_setting_values(defs);
798 lrdf_remove_preset (
const char* ,
const char *setting_uri)
803 char setting_uri_copy[64];
806 strncpy(setting_uri_copy, setting_uri,
sizeof(setting_uri_copy));
808 p.subject = setting_uri_copy;
809 strncpy(buf, LADSPA_BASE
"hasPortValue",
sizeof(buf));
812 q = lrdf_matches(&p);
816 for (i = q; i; i = i->next) {
817 p.subject = i->object;
818 lrdf_remove_matches(&p);
821 lrdf_free_statements(q);
824 strncpy(buf, LADSPA_BASE
"hasSetting",
sizeof(buf));
826 p.object = setting_uri_copy;
827 lrdf_remove_matches(&p);
829 p.subject = setting_uri_copy;
832 lrdf_remove_matches (&p);
841 if (envvar.empty()) {
842 warning <<
_(
"Could not locate HOME. Preset not removed.") <<
endmsg;
852 lrdf_remove_preset (source.c_str(), p->
uri.c_str ());
862 if ((envvar = getenv (
"HOME")) == 0) {
872 return string_compose (
"file:%1/.ladspa/rdf/ardour-presets.n3", envvar);
880 if (g_mkdir_with_parents (path.c_str(), 0775)) {
886 if (g_mkdir_with_parents (path.c_str(), 0775)) {
893 if (lrdf_export_by_source (source.c_str(), source.substr(5).c_str())) {
909 vector<int> input_parameter_pids;
912 input_parameter_pids.push_back (i);
918 if (!isdigit (unique[0])) {
922 uint32_t
const id =
atol (unique.c_str());
924 lrdf_defaults defaults;
925 defaults.count = input_parameter_pids.size ();
926 std::vector<lrdf_portvalue> portvalues(input_parameter_pids.size());
927 defaults.items = &portvalues[0];
929 for (vector<int>::size_type i = 0; i < input_parameter_pids.size(); ++i) {
930 portvalues[i].pid = input_parameter_pids[i];
931 portvalues[i].value =
get_parameter (input_parameter_pids[i]);
935 if (envvar.empty()) {
936 warning <<
_(
"Could not locate HOME. Preset not saved.") <<
endmsg;
942 char* uri_char = lrdf_add_preset (source.c_str(), name.c_str(),
id, &defaults);
943 string uri (uri_char);
959 if (i < _descriptor->PortCount) {
963 warning <<
"LADSPA plugin port index " << i <<
" out of range." <<
endmsg;
int set_state_2X(const XMLNode &, int version)
std::set< Evoral::Parameter > automatable() const
const LADSPA_Descriptor *(* LADSPA_Descriptor_Function)(unsigned long Index)
#define LADSPA_IS_HINT_DEFAULT_LOW(x)
virtual int set_state(const XMLNode &, int version)
float lower
Minimum value (in Hz, for frequencies)
float normal
Default value.
const std::string & value() const
void do_remove_preset(std::string name)
bool parameter_is_output(uint32_t) const
const LADSPA_Descriptor * _descriptor
bool write_preset_file(std::string)
void add_state(XMLNode *) const
virtual void set_parameter(uint32_t which, float val)
#define LADSPA_IS_HINT_TOGGLED(x)
#define LADSPA_IS_HINT_INTEGER(x)
const std::string & name() const
boost::shared_ptr< ScalePoints > get_scale_points(uint32_t port_index) const
std::map< const std::string, const float > ScalePoints
int LADSPA_PortDescriptor
LADSPA_Properties Properties
#define LADSPA_IS_HINT_DEFAULT_100(x)
const char * name() const
LIBPBD_API Transmitter error
LIBPBD_API Transmitter warning
#define LADSPA_IS_HINT_BOUNDED_BELOW(x)
const XMLNodeList & children(const std::string &str=std::string()) const
LADSPA_Handle(* instantiate)(const struct _LADSPA_Descriptor *Descriptor, unsigned long SampleRate)
const char *const * port_names() const
std::string state_node_name() const
std::ostream & endmsg(std::ostream &ostr)
static void init(int fsamp)
#define LADSPA_IS_HINT_DEFAULT_HIGH(x)
framecnt_t frame_rate() const
std::string describe_parameter(Evoral::Parameter)
AudioBuffer & get_audio(size_t i)
static cycles_t get_cycles(void)
#define LADSPA_IS_HINT_SAMPLE_RATE(x)
virtual int connect_and_run(BufferSet &bufs, ChanMapping in, ChanMapping out, pframes_t nframes, framecnt_t offset)
LADSPA_PortRangeHintDescriptor HintDescriptor
std::list< XMLNode * > XMLNodeList
const PresetRecord * preset_by_label(const std::string &)
void run_in_place(pframes_t nsamples)
framecnt_t signal_latency() const
int32_t atol(const string &s)
int connect_and_run(BufferSet &bufs, ChanMapping in, ChanMapping out, pframes_t nframes, framecnt_t offset)
LADSPA_Data * _control_data
boost::shared_ptr< Plugin > PluginPtr
uint32_t nth_parameter(uint32_t port, bool &ok) const
XMLProperty * property(const char *)
void(* run)(LADSPA_Handle Instance, unsigned long SampleCount)
float upper
Maximum value (in Hz, for frequencies)
#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x)
uint32_t parameter_count() const
void set_parameter(uint32_t port, float val)
#define LADSPA_IS_HINT_DEFAULT_0(x)
#define LADSPA_IS_PORT_CONTROL(x)
std::map< std::string, PresetRecord > _presets
const PBD::ID & id() const
#define LADSPA_IS_HINT_DEFAULT_440(x)
int set_state(const XMLNode &, int version)
const char * label() const
void print_parameter(uint32_t, char *, uint32_t len) const
void connect_port(uint32_t port, float *ptr)
void latency_compute_run()
std::string do_save_preset(std::string name)
bool parameter_is_audio(uint32_t) const
LADSPA_PortDescriptor port_descriptor(uint32_t i) const
float _default_value(uint32_t port) const
bool parameter_is_input(uint32_t) const
#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x)
XMLProperty * add_property(const char *name, const std::string &value)
bool parameter_is_control(uint32_t) const
bool load_preset(PresetRecord)
#define LADSPA_IS_PORT_AUDIO(x)
#define LADSPA_IS_INPLACE_BROKEN(x)
void add_child_nocopy(XMLNode &)
const LADSPA_PortRangeHint * port_range_hints() const
bool toggled
True iff parameter is boolean.
#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x)
std::string preset_envvar() const
#define LADSPA_IS_PORT_INPUT(x)
std::string preset_source(std::string) const
ARDOUR::Session & _session
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x)
PluginPtr load(Session &session)
float get_parameter(uint32_t port) const
boost::shared_ptr< ScalePoints > scale_points
#define LADSPA_IS_HINT_LOGARITHMIC(x)
const LADSPA_PortDescriptor * PortDescriptors
LADSPA_Data * _latency_control_port
void set_cycles(uint32_t c)
const Sample * data(framecnt_t offset=0) const
boost::shared_ptr< PluginInfo > PluginInfoPtr
#define LADSPA_IS_PORT_OUTPUT(x)
std::string unique_id() const
#define LADSPA_IS_HINT_HAS_DEFAULT(x)
XMLNodeList::const_iterator XMLNodeConstIterator
BufferSet & get_silent_buffers(ChanCount count=ChanCount::ZERO)
virtual bool load_preset(PresetRecord)
BufferSet & get_scratch_buffers(ChanCount count=ChanCount::ZERO, bool silence=true)
uint32_t get(DataType t, uint32_t from, bool *valid)
#define LADSPA_IS_HINT_DEFAULT_1(x)
std::string string_compose(const std::string &fmt, const T1 &o1)
void init(std::string module_path, uint32_t index, framecnt_t rate)
double atof(const string &s)
LADSPA_Data * _shadow_data
int get_parameter_descriptor(uint32_t which, ParameterDescriptor &) const