[SCM] calf/master: + Provisional LADSPA RDF support + Autoconf-related fixes
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:36:41 UTC 2013
The following commit has been merged in the master branch:
commit 11900a98537c22002a9d5dc8b42169aacd5dff5c
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date: Sat Dec 1 14:37:24 2007 +0000
+ Provisional LADSPA RDF support
+ Autoconf-related fixes
git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@2 78b06b96-2940-0410-b7fc-879d825d01d8
diff --git a/Makefile.am b/Makefile.am
index e36c5a3..d6ea7aa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS = $(SRCDIRS)
distdir = $(PACKAGE)-$(VERSION)
-EXTRADIST = TODO
+EXTRADIST = TODO autogen.sh
clean-local:
rm -f *~ *.old
diff --git a/configure.in b/configure.in
index 6bdbf35..cbfedbe 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([calf],[0.0.1],[wdev at foltman.com])
+AC_INIT([calf],[0.0.2],[wdev at foltman.com])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADER([config.h])
@@ -50,6 +50,14 @@ AC_ARG_WITH(ladspa_dir,
AC_MSG_RESULT($with_ladspa_dir)
AC_SUBST(with_ladspa_dir)
+AC_MSG_CHECKING(where to install LADSPA RDF file)
+AC_ARG_WITH(ladspa_rdf_dir,
+ AC_HELP_STRING([--with-ladspa-rdf-dir],[install RDF file to DIR (default=$prefix/share/ladspa/rdf/)]),
+ ,
+ [with_ladspa_rdf_dir="$prefix/share/ladspa/rdf/"])
+AC_MSG_RESULT($with_ladspa_rdf_dir)
+AC_SUBST(with_ladspa_rdf_dir)
+
# Checks for library functions.
AC_CHECK_FUNCS([floor memset pow])
diff --git a/src/Makefile.am b/src/Makefile.am
index 6449dc1..f5bfc19 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,11 +6,14 @@ SUBDIRS = calf
ladspadir = $(with_ladspa_dir)
-bin_PROGRAMS = calfjackhost
+bin_PROGRAMS = calfjackhost calfmakerdf
calfjackhost_SOURCES = jackhost.cpp
calfjackhost_LDADD = libcalfstatic.la
+calfmakerdf_SOURCES = makerdf.cpp
+calfmakerdf_LDADD = libcalfstatic.la
+
noinst_LTLIBRARIES = libcalf.la libcalfstatic.la
libcalf_la_SOURCES = modules.cpp giface.cpp
@@ -24,10 +27,15 @@ clean-local:
install-data-hook:
install -d -m 755 $(DESTDIR)$(with_ladspa_dir)
+ install -d -m 755 $(DESTDIR)$(with_ladspa_rdf_dir)
install -c -m 755 $(top_builddir)/src/.libs/libcalf.so.0.0.0 $(DESTDIR)$(with_ladspa_dir)/calf.so
+ $(DESTDIR)$(bindir)/calfmakerdf > $(DESTDIR)$(with_ladspa_rdf_dir)/calf.rdf
+#remove calf.so, calf.rdf and - if empty - ladspa dir in usr/share
uninstall-hook:
- $(RM) -f $(with_ladspa_dir)/calf.so
+ $(RM) -f $(DESTDIR)$(with_ladspa_dir)/calf.so
+ $(RM) -f $(DESTDIR)$(with_ladspa_rdf_dir)/calf.rdf
+ rmdir $(DESTDIR)$(with_ladspa_rdf_dir)
#install:
# $(INSTALL) calfjackhost $(bindir)
diff --git a/src/calf/giface.h b/src/calf/giface.h
index 69ee31a..b88cc71 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -57,13 +57,20 @@ enum parameter_flags
PF_CTLOPTIONS = 0xFF0000,
PF_CTLO_HORIZ = 0x010000,
PF_CTLO_VERT = 0x020000,
+
+ PF_UNITS = 0xFF000000,
+ PF_UNIT_DB = 0x01000000,
+ PF_UNIT_COEF = 0x02000000,
+ PF_UNIT_HZ = 0x03000000,
+ PF_UNIT_SEC = 0x04000000,
+ PF_UNIT_MSEC = 0x05000000,
};
struct parameter_properties
{
float def_value, min, max, step;
uint32_t flags;
- const char *choices;
+ const char **choices;
float from_01(float value01);
float to_01(float value);
};
@@ -101,15 +108,19 @@ struct ladspa_info
const char *name;
const char *maker;
const char *copyright;
- const char **port_names;
+ const char *plugin_type;
};
+extern std::string generate_ladspa_rdf(const ladspa_info &info, parameter_properties *params, const char *param_names[], unsigned int count, unsigned int ctl_ofs);
+
template<class Module>
struct ladspa_wrapper
{
LADSPA_Descriptor descriptor;
+ ladspa_info &info;
ladspa_wrapper(ladspa_info &i)
+ : info(i)
{
init_descriptor(i);
}
@@ -126,7 +137,7 @@ struct ladspa_wrapper
descriptor.Copyright = i.copyright;
descriptor.Properties = LADSPA_PROPERTY_INPLACE_BROKEN | (Module::rt_capable ? LADSPA_PROPERTY_HARD_RT_CAPABLE : 0);
descriptor.PortCount = ins + outs + params;
- descriptor.PortNames = i.port_names ? i.port_names : Module::param_names;
+ descriptor.PortNames = Module::param_names;
descriptor.PortDescriptors = new LADSPA_PortDescriptor[descriptor.PortCount];
descriptor.PortRangeHints = new LADSPA_PortRangeHint[descriptor.PortCount];
for (int i = 0; i < ins + outs + params; i++)
@@ -138,7 +149,7 @@ struct ladspa_wrapper
if (i < ins + outs)
prh.HintDescriptor = 0;
else {
- prh.HintDescriptor = LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_DEFAULT_MINIMUM;
+ prh.HintDescriptor = LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_BOUNDED_BELOW;
parameter_properties &pp = Module::param_props[i - ins - outs];
prh.LowerBound = pp.min;
prh.UpperBound = pp.max;
@@ -191,8 +202,11 @@ struct ladspa_wrapper
mod->ins[port] = DataLocation;
else if (port < ins + outs)
mod->outs[port - ins] = DataLocation;
- else if (port < ins + outs + params)
- mod->params[port - ins - outs] = DataLocation;
+ else if (port < ins + outs + params) {
+ int i = port - ins - outs;
+ mod->params[i] = DataLocation;
+ *mod->params[i] = Module::param_props[i].def_value;
+ }
}
static void cb_activate(LADSPA_Handle Instance) {
@@ -222,6 +236,10 @@ struct ladspa_wrapper
Module *const mod = (Module *)Instance;
delete mod;
}
+
+ std::string generate_rdf() {
+ return synth::generate_ladspa_rdf(info, Module::param_props, Module::param_names, Module::param_count, Module::in_count + Module::out_count);
+ };
};
struct audio_exception: public std::exception
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 3c7f6ad..dc2b7e9 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -216,4 +216,6 @@ public:
}
};
+extern std::string get_builtin_modules_rdf();
+
#endif
diff --git a/src/giface.cpp b/src/giface.cpp
index 2e83092..e589356 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -25,6 +25,7 @@
#include <calf/modules.h>
using namespace synth;
+using namespace std;
float parameter_properties::from_01(float value01)
{
@@ -66,3 +67,100 @@ float parameter_properties::to_01(float value)
}
}
+static std::string i2s(int value)
+{
+ char buf[32];
+ sprintf(buf, "%d", value);
+ return buf;
+}
+
+static string f2s(double value)
+{
+ // XXXKF might not work with some locale settings
+ char buf[64];
+ sprintf(buf, "%g", value);
+ return buf;
+}
+
+static string rdf_escape(const string &src)
+{
+ string dest;
+ for (size_t i = 0; i < src.length(); i++) {
+ // XXXKF take care of string encoding
+ if (src[i] < 0 || src[i] == '"' || src[i] == '<' || src[i] == '>' || src[i] == '&')
+ dest += "&"+i2s((uint8_t)src[i])+";";
+ else
+ dest += src[i];
+ }
+ return dest;
+}
+
+static std::string unit_to_string(parameter_properties &props)
+{
+ uint32_t flags = props.flags & PF_UNITS;
+
+ switch(flags) {
+ case PF_UNIT_DB:
+ return "ladspa:hasUnit=\"&ladspa;dB\" ";
+ case PF_UNIT_COEF:
+ return "ladspa:hasUnit=\"&ladspa;coef\" ";
+ case PF_UNIT_HZ:
+ return "ladspa:hasUnit=\"&ladspa;Hz\" ";
+ case PF_UNIT_SEC:
+ return "ladspa:hasUnit=\"&ladspa;seconds\" ";
+ case PF_UNIT_MSEC:
+ return "ladspa:hasUnit=\"&ladspa;milliseconds\" ";
+ default:
+ return string();
+ }
+}
+
+static std::string scale_to_string(parameter_properties &props)
+{
+ if ((props.flags & PF_TYPEMASK) != PF_ENUM) {
+ return "/";
+ }
+ string tmp = "><ladspa:hasScale><ladspa:Scale>\n";
+ for (int i = (int)props.min; i <= (int)props.max; i++) {
+ tmp += " <ladspa:hasPoint><ladspa:Point rdf:value=\""+i2s(i)+"\" ladspa:hasLabel=\""+props.choices[(int)(i - props.min)]+"\" /></ladspa:hasPoint>\n";
+ }
+ return tmp+" </ladspa:Scale></ladspa:hasScale></ladspa:InputControlPort";
+}
+
+std::string synth::generate_ladspa_rdf(const ladspa_info &info, parameter_properties *params, const char *param_names[], unsigned int count,
+ unsigned int ctl_ofs)
+{
+ string rdf;
+ string plugin_id = "&ladspa;" + i2s(info.unique_id);
+ string plugin_type = string(info.plugin_type);
+
+ rdf += " <ladspa:" + plugin_type + " rdf:about=\"" + plugin_id + "\">\n";
+ rdf += " <dc:creator>" + rdf_escape(info.maker) + "</dc:creator>\n";
+ rdf += " <dc:title>" + rdf_escape(info.name) + "</dc:title>\n";
+
+ for (unsigned int i = 0; i < count; i++) {
+ rdf +=
+ " <ladspa:hasPort>\n"
+ " <ladspa:InputControlPort rdf:about=\"" + plugin_id + "."+i2s(i )+"\" "
+ + unit_to_string(params[i]) +
+ "ladspa:hasLabel=\"par_"+i2s(i + ctl_ofs)+"\" "
+ + scale_to_string(params[i]) +
+ ">\n"
+ " </ladspa:hasPort>\n";
+ }
+ rdf += " <ladspa:hasSetting>\n"
+ " <ladspa:Default>\n";
+ for (unsigned int i = 0; i < count; i++) {
+ rdf +=
+ " <ladspa:hasPortValue>\n"
+ " <ladspa:PortValue rdf:value=\"" + f2s(params[i].def_value) + "\">\n"
+ " <ladspa:forPort rdf:resource=\"" + plugin_id + "." + i2s(i ) + "\"/>\n"
+ " </ladspa:PortValue>\n"
+ " </ladspa:hasPortValue>\n";
+ }
+ rdf += " </ladspa:Default>\n"
+ " </ladspa:hasSetting>\n";
+
+ rdf += " </ladspa:" + plugin_type + ">\n";
+ return rdf;
+}
diff --git a/src/makerdf.cpp b/src/makerdf.cpp
new file mode 100644
index 0000000..c7d8f58
--- /dev/null
+++ b/src/makerdf.cpp
@@ -0,0 +1,55 @@
+#include <getopt.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <config.h>
+#include <jack/jack.h>
+#include <calf/giface.h>
+#include <calf/modules.h>
+
+using namespace std;
+
+static struct option long_options[] = {
+ {"help", 0, 0, 'h'},
+ {"version", 0, 0, 'v'},
+ {"client", 1, 0, 'c'},
+ {"effect", 1, 0, 'e'},
+ {"input", 1, 0, 'i'},
+ {"output", 1, 0, 'o'},
+ {0,0,0,0},
+};
+
+int main(int argc, char *argv[])
+{
+ while(1) {
+ int option_index;
+ int c = getopt_long(argc, argv, "c:e:i:o:hv", long_options, &option_index);
+ if (c == -1)
+ break;
+ switch(c) {
+ case 'h':
+ printf("LADSPA RDF generator for Calf plugin pack\nSyntax: %s [--help] [--version]\n", argv[0]);
+ return 0;
+ case 'v':
+ printf("%s\n", PACKAGE_STRING);
+ return 0;
+ }
+ }
+ string rdf;
+ rdf =
+ "<?xml version='1.0' encoding='ISO-8859-1'?>\n"
+ "<!DOCTYPE rdf:RDF [\n"
+ " <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>\n"
+ " <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>\n"
+ " <!ENTITY dc 'http://purl.org/dc/elements/1.1/'>\n"
+ " <!ENTITY ladspa 'http://ladspa.org/ontology#'>\n"
+ "]>\n";
+
+ rdf += "<rdf:RDF xmlns:rdf=\"&rdf;\" xmlns:rdfs=\"&rdfs;\" xmlns:dc=\"&dc;\" xmlns:ladspa=\"&ladspa;\">\n";
+
+ rdf += get_builtin_modules_rdf();
+
+ rdf += "</rdf:RDF>\n";
+
+ printf("%s\n", rdf.c_str());
+ return 0;
+}
diff --git a/src/modules.cpp b/src/modules.cpp
index 5e8e833..8192099 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -32,7 +32,7 @@ parameter_properties amp_audio_module::param_props[] = {
{ 1, 0, 4, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL }
};
-static synth::ladspa_info amp_info = { 0x847c, "Amp", "Calf Const Amp", "Krzysztof Foltman", copyright, NULL };
+static synth::ladspa_info amp_info = { 0x847c, "Amp", "Calf Const Amp", "Krzysztof Foltman", copyright, "AmplifierPlugin" };
synth::ladspa_wrapper<amp_audio_module> amp(amp_info);
@@ -41,14 +41,14 @@ synth::ladspa_wrapper<amp_audio_module> amp(amp_info);
const char *flanger_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Min. delay", "Mod. depth", "Mod. rate", "Feedback", "Amount"};
parameter_properties flanger_audio_module::param_props[] = {
- { 0.1, 0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 0.5, 0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 0.25, 0.01, 20, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 0.90, -0.99, 0.99, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB, NULL },
- { 1, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL },
+ { 0.1, 0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
+ { 0.5, 0.1, 10, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_MSEC, NULL },
+ { 0.25, 0.01, 20, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
+ { 0.90, -0.99, 0.99, 1.01, PF_FLOAT | PF_SCALE_PERC | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
+ { 1, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
};
-static synth::ladspa_info flanger_info = { 0x847d, "Flanger", "Calf Flanger", "Krzysztof Foltman", copyright, NULL };
+static synth::ladspa_info flanger_info = { 0x847d, "Flanger", "Calf Flanger", "Krzysztof Foltman", copyright, "FlangerPlugin" };
synth::ladspa_wrapper<flanger_audio_module> flanger(flanger_info);
@@ -57,12 +57,12 @@ synth::ladspa_wrapper<flanger_audio_module> flanger(flanger_info);
const char *reverb_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Dec. time", "HF Damp", "Amount"};
parameter_properties reverb_audio_module::param_props[] = {
- { 1.5, 1.0, 4.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 5000, 2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 0.25, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL },
+ { 1.5, 1.0, 4.0, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_SEC, NULL },
+ { 5000, 2000,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
+ { 0.25, 0, 2, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF, NULL },
};
-static synth::ladspa_info reverb_info = { 0x847e, "Reverb", "Calf Reverb", "Krzysztof Foltman", copyright, NULL };
+static synth::ladspa_info reverb_info = { 0x847e, "Reverb", "Calf Reverb", "Krzysztof Foltman", copyright, "ReverbPlugin" };
synth::ladspa_wrapper<reverb_audio_module> reverb(reverb_info);
@@ -70,13 +70,18 @@ synth::ladspa_wrapper<reverb_audio_module> reverb(reverb_info);
const char *filter_audio_module::param_names[] = {"In L", "In R", "Out L", "Out R", "Cutoff", "Resonance", "Mode"};
+const char *filter_choices[] = {
+ "Lowpass",
+ "Highpass"
+};
+
parameter_properties filter_audio_module::param_props[] = {
- { 2000, 20,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB, NULL },
- { 0.707, 0.707, 20, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB, NULL },
- { 0, 0, 1, 1, PF_INT | PF_CTL_COMBO, "Lowpass\0Highpass\0" },
+ { 2000, 20,20000, 1.01, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL },
+ { 0.707, 0.707, 20, 1.1, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL },
+ { 0, 0, 1, 1, PF_ENUM | PF_CTL_COMBO, filter_choices },
};
-static synth::ladspa_info filter_info = { 0x847f, "Filter", "Calf Filter", "Krzysztof Foltman", copyright, NULL };
+static synth::ladspa_info filter_info = { 0x847f, "Filter", "Calf Filter", "Krzysztof Foltman", copyright, "FilterPlugin" };
synth::ladspa_wrapper<filter_audio_module> filter(filter_info);
@@ -96,3 +101,13 @@ const LADSPA_Descriptor *ladspa_descriptor(unsigned long Index)
};
+std::string get_builtin_modules_rdf()
+{
+ std::string rdf;
+
+ rdf += flanger.generate_rdf();
+ rdf += reverb.generate_rdf();
+ rdf += filter.generate_rdf();
+
+ return rdf;
+}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list