X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fpluginlv2config.C;fp=cinelerra-5.1%2Fcinelerra%2Fpluginlv2config.C;h=776f9d67b15b53982b14d593a8dbf965465067f4;hb=efb3600851fd27b13d3053ffbdb6434535580bfd;hp=0000000000000000000000000000000000000000;hpb=83fa73bc0a258573fbbe06965f36dde3f8325688;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/pluginlv2config.C b/cinelerra-5.1/cinelerra/pluginlv2config.C new file mode 100644 index 00000000..776f9d67 --- /dev/null +++ b/cinelerra-5.1/cinelerra/pluginlv2config.C @@ -0,0 +1,234 @@ +#ifdef HAVE_LV2 + +/* + * CINELERRA + * Copyright (C) 2018 GG + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "arraylist.h" +#include "cstrdup.h" +#include "language.h" +#include "pluginlv2config.h" + +#include +#include + +PluginLV2UriTable::PluginLV2UriTable() +{ + set_array_delete(); +} + +PluginLV2UriTable::~PluginLV2UriTable() +{ + remove_all_objects(); +} + +LV2_URID PluginLV2UriTable::map(const char *uri) +{ + mLock locker(uri_table_lock); + for( int i=0; i=0 && idxopt = opt; + set_text(opt->get_name()); +} + +PluginLV2Client_OptValue::PluginLV2Client_OptValue(PluginLV2Client_Opt *opt) +{ + this->opt = opt; + update(); +} + +int PluginLV2Client_OptValue::update() +{ + char val[BCSTRLEN]; + sprintf(val, "%f", opt->get_value()); + if( !strcmp(val, get_text()) ) return 0; + set_text(val); + return 1; +} + + +PluginLV2Client_Opt::PluginLV2Client_Opt(PluginLV2ClientConfig *conf, int idx) +{ + this->conf = conf; + this->idx = idx; + item_name = new PluginLV2Client_OptName(this); + item_value = new PluginLV2Client_OptValue(this); +} + +PluginLV2Client_Opt::~PluginLV2Client_Opt() +{ + delete item_name; + delete item_value; +} + +float PluginLV2Client_Opt::get_value() +{ + return conf->ctls[idx]; +} + +const char *PluginLV2Client_Opt::get_symbol() +{ + return conf->syms[idx]; +} + +void PluginLV2Client_Opt::set_value(float v) +{ + conf->ctls[idx] = v; +} + +int PluginLV2Client_Opt::update(float v) +{ + set_value(v); + return item_value->update(); +} + +const char *PluginLV2Client_Opt::get_name() +{ + return conf->names[idx]; +} + +PluginLV2ClientConfig::PluginLV2ClientConfig() +{ + names = 0; + syms = 0; + mins = 0; + maxs = 0; + ctls = 0; + nb_ports = 0; +} + +PluginLV2ClientConfig::~PluginLV2ClientConfig() +{ + reset(); + remove_all_objects(); +} + +void PluginLV2ClientConfig::reset() +{ + for( int i=0; iget_value(), vopt->get_value()) ) return 0; + } + return 1; +} + +void PluginLV2ClientConfig::copy_from(PluginLV2ClientConfig &that) +{ + if( nb_ports != that.nb_ports ) { + reset(); + nb_ports = that.nb_ports; + names = new const char *[nb_ports]; + syms = new const char *[nb_ports]; + for( int i=0; iidx)); + } +} + +void PluginLV2ClientConfig::interpolate(PluginLV2ClientConfig &prev, PluginLV2ClientConfig &next, + int64_t prev_frame, int64_t next_frame, int64_t current_frame) +{ + copy_from(prev); +} + +void PluginLV2ClientConfig::init_lv2(const LilvPlugin *lilv) +{ + reset(); + nb_ports = lilv_plugin_get_num_ports(lilv); + names = new const char *[nb_ports]; + syms = new const char *[nb_ports]; + mins = new float[nb_ports]; + maxs = new float[nb_ports]; + ctls = new float[nb_ports]; + lilv_plugin_get_port_ranges_float(lilv, mins, maxs, ctls); + for( int i=0; iitem_value->update() ) ++ret; + } + return ret; +} + +void PluginLV2ClientConfig::dump(FILE *fp) +{ + fprintf(fp, "Controls:\n"); + for( int i=0; iidx, get(i)->get_symbol(), get(i)->get_value()); + } + fprintf(fp, "Ports:\n"); + for( int i=0; i