146 lines
4.8 KiB
C++
146 lines
4.8 KiB
C++
/*
|
|
Copyright 2013 Peter Nelson
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <lv2.h>
|
|
#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
|
|
#include "ptap.h"
|
|
|
|
static bool _last;
|
|
|
|
static void addport(FILE *fp, const char *type, const char *type2, const char *symbol, const char *name, int index, const char *additional = "")
|
|
{
|
|
fprintf(fp,
|
|
" [\n"
|
|
" a lv2:%s , lv2:%s ;\n"
|
|
" lv2:index %d ;\n"
|
|
" lv2:symbol \"%s\" ;\n"
|
|
" lv2:name \"%s\" ;\n"
|
|
"%s"
|
|
" ]%c\n",
|
|
type, type2, index, symbol, name, additional,_last ? '.' : ',');
|
|
}
|
|
|
|
static void addttl(const char *file)
|
|
{
|
|
FILE *fp = fopen(file, "w");
|
|
char symbol[128];
|
|
char name[128];
|
|
|
|
fputs( "@prefix lv2: <" LV2_CORE_URI "#> .\n"
|
|
"@prefix ui: <" LV2_UI_URI "#> .\n"
|
|
"@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n"
|
|
"@prefix doap: <http://usefulinc.com/ns/doap#> .\n"
|
|
"\n"
|
|
"<" PTAP_URI ">\n"
|
|
" a lv2:Plugin , lv2:DelayPlugin ;\n"
|
|
" lv2:binary <ptap.so> ;\n"
|
|
" doap:maintainer [\n"
|
|
" foaf:name \"Peter Nelson\" ;\n"
|
|
" foaf:homepage <http://fuzzle.org/~petern/ptap/> ;\n"
|
|
" foaf:mbox <mailto:peter@fuzzle.org> ;\n"
|
|
" ];\n"
|
|
" doap:name \"PTap\" ;\n"
|
|
" doap:license <http://usefulinc.com/doap/licenses/gpl> ;\n"
|
|
" ui:ui <" PTAP_URI "#X11UI> ;\n"
|
|
" ui:ui <" PTAP_URI "#ExtUI> ;\n"
|
|
" lv2:port\n"
|
|
, fp);
|
|
|
|
for (int i = 0; i < NUM_CHANNELS; i++) {
|
|
sprintf(symbol, "in_%d", i + 1);
|
|
sprintf(name, "Audio In %d", i + 1);
|
|
addport(fp, "InputPort", "AudioPort", symbol, name, TAP_INS + i);
|
|
}
|
|
for (int i = 0; i < NUM_CHANNELS; i++) {
|
|
sprintf(symbol, "out_%d", i + 1);
|
|
sprintf(name, "Audio Out %d", i + 1);
|
|
addport(fp, "OutputPort", "AudioPort", symbol, name, TAP_OUTS + i);
|
|
}
|
|
for (int i = 0; i < NUM_TAPS; i++) {
|
|
for (int j = 0; j < NUM_TAPS; j++) {
|
|
sprintf(symbol, "tap_%d_gain_%d", i + 1, j + 1);
|
|
sprintf(name, "Tap %d - Gain %d", i + 1, j + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_MATRIX + i * NUM_GAINS + j,
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
}
|
|
for (int j = 0; j < NUM_CHANNELS; j++) {
|
|
sprintf(symbol, "tap_%d_input_%d", i + 1, j + 1);
|
|
sprintf(name, "Tap %d - Input %d", i + 1, j + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_MATRIX + i * NUM_GAINS + NUM_TAPS + j,
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
}
|
|
sprintf(symbol, "tap_%d_gain", i + 1);
|
|
sprintf(name, "Tap %d - Gain", i + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_GAINS + i,
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
|
|
sprintf(symbol, "tap_%d_delay", i + 1);
|
|
sprintf(name, "Tap %d - Delay", i + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_DELAYS + i,
|
|
" lv2:minimum 0.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 10.0 ;\n");
|
|
}
|
|
for (int i = 0; i < NUM_CHANNELS; i++) {
|
|
for (int j = 0; j < NUM_TAPS; j++) {
|
|
sprintf(symbol, "out_%d_gain_%d", i + 1, j + 1);
|
|
sprintf(name, "Output %d - Gain %d", i + 1, j + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_MATRIX + (i + NUM_TAPS) * NUM_GAINS + j,
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
}
|
|
for (int j = 0; j < NUM_CHANNELS; j++) {
|
|
sprintf(symbol, "out_%d_input_%d", i + 1, j + 1);
|
|
sprintf(name, "Output %d - Input %d", i + 1, j + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_MATRIX + (i + NUM_TAPS) * NUM_GAINS + NUM_TAPS + j,
|
|
i == j ?
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 1.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n"
|
|
:
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 0.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
}
|
|
if (i == NUM_CHANNELS - 1) _last = true;
|
|
sprintf(symbol, "out_%d_gain", i + 1);
|
|
sprintf(name, "Output %d - Gain", i + 1);
|
|
addport(fp, "InputPort", "ControlPort", symbol, name, TAP_GAINS + NUM_TAPS + i,
|
|
" lv2:minimum -1.0 ;\n"
|
|
" lv2:default 1.0 ;\n"
|
|
" lv2:maximum 1.0 ;\n");
|
|
}
|
|
|
|
fclose(fp);
|
|
}
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
if (!strcmp(argv[1], "rdf")) {
|
|
addttl(argv[2]);
|
|
} else if (!strcmp(argv[1], "h")) {
|
|
}
|
|
}
|