Add helper util to build rdf.
parent
d86d43eddd
commit
a460b65485
|
@ -1,3 +1,4 @@
|
|||
|
||||
CFLAGS := -Wall -O3 -g -D_GNU_SOURCE
|
||||
LDFLAGS := -lm
|
||||
|
||||
|
@ -9,7 +10,7 @@ $(PTAPOBJ): CFLAGS += `pkg-config lv2 --cflags`
|
|||
$(PTAPO): LDFLAGS += `pkg-config lv2 --libs`
|
||||
|
||||
PTAPUISRC := ptapui.cpp
|
||||
PTAPUIOBJ := $(PTAPUISRC:.cpp=.o) ../pui/*.o
|
||||
PTAPUIOBJ := $(PTAPUISRC:.cpp=.o)
|
||||
PTAPUIO := ptapui.so
|
||||
|
||||
$(PTAPUIOBJ): CFLAGS += `pkg-config lv2 ftgl pugl-0 --cflags`
|
||||
|
@ -17,7 +18,7 @@ $(PTAPUIO): LDFLAGS += `pkg-config lv2 ftgl pugl-0 --libs`
|
|||
|
||||
CPP := g++
|
||||
|
||||
all: $(PTAPO) $(PTAPUIO)
|
||||
all: $(PTAPO) $(PTAPUIO) ptap.ttl
|
||||
|
||||
clean:
|
||||
rm $(PTAPOBJ) $(PTAPO) $(PTAPUIOBJ) $(PTAPUIO)
|
||||
|
@ -25,11 +26,21 @@ clean:
|
|||
depend:
|
||||
makedepend $(PTAPSRC)
|
||||
|
||||
ptap.ttl: ptap_helper
|
||||
./ptap_helper rdf $@
|
||||
|
||||
ptap_helper: ptap_helper.cpp ptap.h
|
||||
$(CPP) $(CFLAGS) $(LDFLAGS) $< -o $@
|
||||
|
||||
$(PTAPOBJ): $(PTAPSRC) ptap.h
|
||||
|
||||
$(PTAPUIOBJ): $(PTAPUISRC) ptap.h
|
||||
|
||||
$(PTAPO): $(PTAPOBJ)
|
||||
$(CPP) $(LDFLAGS) -shared -fPIC -Wl,-soname,$(PTAPO) $(PTAPOBJ) -o $@
|
||||
|
||||
$(PTAPUIO): $(PTAPUIOBJ)
|
||||
$(CPP) $(LDFLAGS) -shared -fPIC -Wl,-soname,$(PTAPUIO) $(PTAPUIOBJ) -o $@
|
||||
$(PTAPUIO): $(PTAPUIOBJ) ../pui/*.o
|
||||
$(CPP) $(LDFLAGS) -shared -fPIC -Wl,-soname,$(PTAPUIO) $(PTAPUIOBJ) ../pui/*.o -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
$(CPP) -c -fPIC $(CFLAGS) $< -o $@
|
||||
|
|
210
ptap/default.ttl
210
ptap/default.ttl
|
@ -11,243 +11,237 @@
|
|||
lv2:appliesTo <urn:fuzzle:ptap> ;
|
||||
rdfs:label "Default" ;
|
||||
lv2:port [
|
||||
lv2:symbol "left_1_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_2_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_3_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_4_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_5_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_6_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_gain" ;
|
||||
lv2:symbol "out_1_gain" ;
|
||||
pset:value 1.0
|
||||
] , [
|
||||
lv2:symbol "left_l_gain" ;
|
||||
lv2:symbol "out_1_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_1_input_1" ;
|
||||
pset:value 1.0
|
||||
] , [
|
||||
lv2:symbol "left_r_gain" ;
|
||||
lv2:symbol "out_1_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "left_unused" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_1_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_2_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_3_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_4_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_5_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_6_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_gain" ;
|
||||
lv2:symbol "out_2_gain" ;
|
||||
pset:value 1.0
|
||||
] , [
|
||||
lv2:symbol "right_l_gain" ;
|
||||
lv2:symbol "out_2_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "right_r_gain" ;
|
||||
lv2:symbol "out_2_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "out_2_input_2" ;
|
||||
pset:value 1.0
|
||||
] , [
|
||||
lv2:symbol "right_unused" ;
|
||||
lv2:symbol "tap_1_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_1_gain" ;
|
||||
lv2:symbol "tap_1_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_2_gain" ;
|
||||
lv2:symbol "tap_1_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_3_gain" ;
|
||||
lv2:symbol "tap_1_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_4_gain" ;
|
||||
lv2:symbol "tap_1_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_5_gain" ;
|
||||
lv2:symbol "tap_1_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_6_gain" ;
|
||||
lv2:symbol "tap_1_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_delay" ;
|
||||
lv2:symbol "tap_1_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_gain" ;
|
||||
lv2:symbol "tap_1_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_l_gain" ;
|
||||
lv2:symbol "tap_1_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t1_r_gain" ;
|
||||
lv2:symbol "tap_2_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_1_gain" ;
|
||||
lv2:symbol "tap_2_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_2_gain" ;
|
||||
lv2:symbol "tap_2_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_3_gain" ;
|
||||
lv2:symbol "tap_2_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_4_gain" ;
|
||||
lv2:symbol "tap_2_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_5_gain" ;
|
||||
lv2:symbol "tap_2_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_6_gain" ;
|
||||
lv2:symbol "tap_2_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_delay" ;
|
||||
lv2:symbol "tap_2_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_gain" ;
|
||||
lv2:symbol "tap_2_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_l_gain" ;
|
||||
lv2:symbol "tap_2_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t2_r_gain" ;
|
||||
lv2:symbol "tap_3_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_1_gain" ;
|
||||
lv2:symbol "tap_3_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_2_gain" ;
|
||||
lv2:symbol "tap_3_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_3_gain" ;
|
||||
lv2:symbol "tap_3_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_4_gain" ;
|
||||
lv2:symbol "tap_3_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_5_gain" ;
|
||||
lv2:symbol "tap_3_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_6_gain" ;
|
||||
lv2:symbol "tap_3_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_delay" ;
|
||||
lv2:symbol "tap_3_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_gain" ;
|
||||
lv2:symbol "tap_3_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_l_gain" ;
|
||||
lv2:symbol "tap_3_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t3_r_gain" ;
|
||||
lv2:symbol "tap_4_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_2_gain" ;
|
||||
lv2:symbol "tap_4_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_3_gain" ;
|
||||
lv2:symbol "tap_4_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_4_gain" ;
|
||||
lv2:symbol "tap_4_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_4_gain" ;
|
||||
lv2:symbol "tap_4_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_5_gain" ;
|
||||
lv2:symbol "tap_4_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_6_gain" ;
|
||||
lv2:symbol "tap_4_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_delay" ;
|
||||
lv2:symbol "tap_4_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_gain" ;
|
||||
lv2:symbol "tap_4_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_l_gain" ;
|
||||
lv2:symbol "tap_4_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t4_r_gain" ;
|
||||
lv2:symbol "tap_5_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_2_gain" ;
|
||||
lv2:symbol "tap_5_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_3_gain" ;
|
||||
lv2:symbol "tap_5_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_4_gain" ;
|
||||
lv2:symbol "tap_5_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_5_gain" ;
|
||||
lv2:symbol "tap_5_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_5_gain" ;
|
||||
lv2:symbol "tap_5_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_6_gain" ;
|
||||
lv2:symbol "tap_5_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_delay" ;
|
||||
lv2:symbol "tap_5_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_gain" ;
|
||||
lv2:symbol "tap_5_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_l_gain" ;
|
||||
lv2:symbol "tap_5_input_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t5_r_gain" ;
|
||||
lv2:symbol "tap_6_delay" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_2_gain" ;
|
||||
lv2:symbol "tap_6_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_3_gain" ;
|
||||
lv2:symbol "tap_6_gain_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_4_gain" ;
|
||||
lv2:symbol "tap_6_gain_2" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_5_gain" ;
|
||||
lv2:symbol "tap_6_gain_3" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_6_gain" ;
|
||||
lv2:symbol "tap_6_gain_4" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_6_gain" ;
|
||||
lv2:symbol "tap_6_gain_5" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_delay" ;
|
||||
lv2:symbol "tap_6_gain_6" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_gain" ;
|
||||
lv2:symbol "tap_6_input_1" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_l_gain" ;
|
||||
pset:value 0.0
|
||||
] , [
|
||||
lv2:symbol "t6_r_gain" ;
|
||||
lv2:symbol "tap_6_input_2" ;
|
||||
pset:value 0.0
|
||||
] .
|
||||
|
|
126
ptap/ptap.cpp
126
ptap/ptap.cpp
|
@ -4,34 +4,27 @@
|
|||
#include <cstring>
|
||||
#include <math.h>
|
||||
#include <lv2.h>
|
||||
#include "ptap.h"
|
||||
|
||||
#define CHANNELS 2
|
||||
#define TAPS 6
|
||||
#define BUFFER_SECONDS 10
|
||||
|
||||
struct Tap {
|
||||
float *t_gain[TAPS + CHANNELS];
|
||||
float *gain;
|
||||
float *delay;
|
||||
};
|
||||
|
||||
static const int CONTROLS_PER_TAP = sizeof (Tap) / sizeof (float *);
|
||||
|
||||
struct PTap
|
||||
{
|
||||
double sample_rate;
|
||||
size_t buffer_max;
|
||||
|
||||
Tap tap[TAPS + CHANNELS];
|
||||
/* Ports */
|
||||
struct {
|
||||
float *in[NUM_CHANNELS];
|
||||
float *out[NUM_CHANNELS];
|
||||
float *matrix[NUM_GAINS][NUM_GAINS];
|
||||
float *gain[NUM_GAINS];
|
||||
float *delay[NUM_TAPS];
|
||||
} ports;
|
||||
|
||||
float *buffers[TAPS]; ///< Tap audio buffers
|
||||
const float *buffers_end[TAPS]; ///< Audio buffer end points
|
||||
float *wp[TAPS]; ///< Write pointers
|
||||
|
||||
float *in_l;
|
||||
float *in_r;
|
||||
float *out_l;
|
||||
float *out_r;
|
||||
float *buffers[NUM_TAPS]; ///< Tap audio buffers
|
||||
const float *buffers_end[NUM_TAPS]; ///< Audio buffer end points
|
||||
float *wp[NUM_TAPS]; ///< Write pointers
|
||||
};
|
||||
|
||||
static LV2_Handle ptap_instantiate(
|
||||
|
@ -45,7 +38,7 @@ static LV2_Handle ptap_instantiate(
|
|||
ptap->sample_rate = sample_rate;
|
||||
ptap->buffer_max = ptap->sample_rate * BUFFER_SECONDS + 1;
|
||||
|
||||
for (int i = 0; i < TAPS; i++) {
|
||||
for (int i = 0; i < NUM_TAPS; i++) {
|
||||
ptap->buffers[i] = new float[ptap->buffer_max]();
|
||||
|
||||
if (ptap->buffers[i] == NULL) {
|
||||
|
@ -68,54 +61,53 @@ static LV2_Handle ptap_instantiate(
|
|||
static void ptap_connect_port(LV2_Handle lv2instance, uint32_t port, void *data)
|
||||
{
|
||||
PTap *ptap = (PTap *)lv2instance;
|
||||
Tap *tap;
|
||||
float *fdata = (float *)data;
|
||||
|
||||
/* Audio ports */
|
||||
if (port < 4) {
|
||||
switch (port) {
|
||||
case 0: ptap->in_l = fdata; break;
|
||||
case 1: ptap->in_r = fdata; break;
|
||||
case 2: ptap->out_l = fdata; break;
|
||||
case 3: ptap->out_r = fdata; break;
|
||||
}
|
||||
if (port >= TAP_INS && port < TAP_OUTS) {
|
||||
port -= TAP_INS;
|
||||
ptap->ports.in[port] = fdata;
|
||||
return;
|
||||
}
|
||||
|
||||
if (port >= TAP_OUTS && port < TAP_MATRIX) {
|
||||
port -= TAP_OUTS;
|
||||
ptap->ports.out[port] = fdata;
|
||||
return;
|
||||
}
|
||||
|
||||
port -= 4;
|
||||
|
||||
int tap_index = port / CONTROLS_PER_TAP;
|
||||
|
||||
if (tap_index < TAPS + CHANNELS) {
|
||||
tap = &ptap->tap[tap_index];
|
||||
} else {
|
||||
if (port >= TAP_MATRIX && port < TAP_GAINS) {
|
||||
port -= TAP_MATRIX;
|
||||
ptap->ports.matrix[port / NUM_GAINS][port % NUM_GAINS] = fdata;
|
||||
return;
|
||||
}
|
||||
|
||||
int tap_port = port % CONTROLS_PER_TAP;
|
||||
|
||||
if (tap_port < TAPS + CHANNELS) {
|
||||
tap->t_gain[tap_port] = fdata;
|
||||
} else if (tap_port - TAPS == 2) {
|
||||
tap->gain = fdata;
|
||||
} else if (tap_port - TAPS == 3) {
|
||||
tap->delay = fdata;
|
||||
} else {
|
||||
if (port >= TAP_GAINS && port < TAP_DELAYS) {
|
||||
port -= TAP_GAINS;
|
||||
ptap->ports.gain[port] = fdata;
|
||||
return;
|
||||
}
|
||||
|
||||
if (port >= TAP_DELAYS && port < TAP_END) {
|
||||
port -= TAP_DELAYS;
|
||||
ptap->ports.delay[port] = fdata;
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Unknown port index %u\n", port);
|
||||
}
|
||||
|
||||
static void ptap_run(LV2_Handle lv2instance, uint32_t sample_count)
|
||||
{
|
||||
PTap *ptap = (PTap *)lv2instance;
|
||||
|
||||
const float *readp[TAPS + CHANNELS];
|
||||
float gain[TAPS + CHANNELS];
|
||||
const float *readp[NUM_GAINS];
|
||||
float gain[NUM_GAINS];
|
||||
bool check_overflow = false;
|
||||
|
||||
/* Position read pointers behind write pointers */
|
||||
for (int i = 0; i < TAPS; i++) {
|
||||
int delay = *ptap->tap[i].delay * ptap->sample_rate;
|
||||
for (int i = 0; i < NUM_TAPS; i++) {
|
||||
int delay = *ptap->ports.delay[i] * ptap->sample_rate;
|
||||
/* Zero delay results in processing order dependencies. Tapiir doesn't permit it either... */
|
||||
if (delay < 1) delay = 1;
|
||||
readp[i] = ptap->wp[i] - delay;
|
||||
|
@ -124,41 +116,37 @@ static void ptap_run(LV2_Handle lv2instance, uint32_t sample_count)
|
|||
}
|
||||
if (ptap->wp[i] + sample_count >= ptap->buffers_end[i]) check_overflow = true;
|
||||
if (readp[i] + sample_count >= ptap->buffers_end[i]) check_overflow = true;
|
||||
gain[i] = *ptap->tap[i].gain;
|
||||
gain[i] = *ptap->ports.gain[i];
|
||||
}
|
||||
|
||||
float *out_l = ptap->out_l;
|
||||
float *out_r = ptap->out_r;
|
||||
|
||||
readp[TAPS ] = ptap->in_l;
|
||||
readp[TAPS + 1] = ptap->in_r;
|
||||
gain[TAPS ] = *ptap->tap[TAPS ].gain;
|
||||
gain[TAPS + 1] = *ptap->tap[TAPS + 1].gain;
|
||||
float *out[NUM_CHANNELS];
|
||||
for (int i = 0; i < NUM_CHANNELS; i++) {
|
||||
out[i] = ptap->ports.out[i];
|
||||
readp[NUM_TAPS + i] = ptap->ports.in[i];
|
||||
gain[NUM_TAPS + i] = *ptap->ports.gain[NUM_TAPS + i];
|
||||
}
|
||||
|
||||
while (sample_count--) {
|
||||
float rp[TAPS + CHANNELS];
|
||||
float wp[TAPS + CHANNELS];
|
||||
float rp[NUM_GAINS];
|
||||
float wp[NUM_GAINS];
|
||||
|
||||
/* Read input to local buffers */
|
||||
for (int i = 0; i < TAPS + CHANNELS; i++) rp[i] = *readp[i]++;
|
||||
for (int i = 0; i < NUM_GAINS; i++) rp[i] = *readp[i]++;
|
||||
|
||||
/* Process delays */
|
||||
for (int i = 0; i < TAPS + CHANNELS; i++) {
|
||||
const Tap *tap = &ptap->tap[i];
|
||||
|
||||
for (int i = 0; i < NUM_GAINS; i++) {
|
||||
float sample = 0;
|
||||
for (int j = 0; j < TAPS + CHANNELS; j++) sample += rp[j] * *tap->t_gain[j];
|
||||
for (int j = 0; j < NUM_GAINS; j++) sample += rp[j] * *ptap->ports.matrix[i][j];
|
||||
wp[i] = sample * gain[i];
|
||||
}
|
||||
|
||||
/* Write outputs */
|
||||
for (int i = 0; i < TAPS; i++) *ptap->wp[i]++ = wp[i];
|
||||
*out_l++ = wp[TAPS];
|
||||
*out_r++ = wp[TAPS + 1];
|
||||
for (int i = 0; i < NUM_TAPS; i++) *ptap->wp[i]++ = wp[i];
|
||||
for (int i = 0; i < NUM_CHANNELS; i++) *out[i]++ = wp[NUM_TAPS + i];
|
||||
|
||||
/* Check read/write pointers */
|
||||
if (check_overflow) {
|
||||
for (int i = 0; i < TAPS; i++) {
|
||||
for (int i = 0; i < NUM_TAPS; i++) {
|
||||
if (ptap->wp[i] >= ptap->buffers_end[i]) ptap->wp[i] = ptap->buffers[i];
|
||||
if (readp[i] >= ptap->buffers_end[i]) readp[i] = ptap->buffers[i];
|
||||
}
|
||||
|
@ -170,7 +158,7 @@ static void ptap_cleanup(LV2_Handle lv2instance)
|
|||
{
|
||||
PTap *ptap = (PTap *)lv2instance;
|
||||
|
||||
for (int i = 0; i < TAPS; i++) {
|
||||
for (int i = 0; i < NUM_TAPS; i++) {
|
||||
delete ptap->buffers[i];
|
||||
}
|
||||
|
||||
|
@ -179,7 +167,7 @@ static void ptap_cleanup(LV2_Handle lv2instance)
|
|||
|
||||
static const LV2_Descriptor s_lv2descriptor =
|
||||
{
|
||||
"urn:fuzzle:ptap",
|
||||
PTAP_URI,
|
||||
&ptap_instantiate,
|
||||
&ptap_connect_port,
|
||||
NULL,
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef PTAP_H
|
||||
#define PTAP_H
|
||||
|
||||
#define PTAP_URI "urn:fuzzle:ptap"
|
||||
|
||||
#define NUM_TAPS 6
|
||||
#define NUM_CHANNELS 2
|
||||
|
||||
#define NUM_GAINS (NUM_TAPS + NUM_CHANNELS)
|
||||
|
||||
enum {
|
||||
TAP_INS,
|
||||
TAP_OUTS = TAP_INS + NUM_CHANNELS,
|
||||
TAP_MATRIX = TAP_OUTS + NUM_CHANNELS,
|
||||
TAP_GAINS = TAP_MATRIX + NUM_GAINS * NUM_GAINS,
|
||||
TAP_DELAYS = TAP_GAINS + NUM_GAINS,
|
||||
TAP_END = TAP_DELAYS + NUM_TAPS,
|
||||
};
|
||||
|
||||
#endif /* PTAP_H */
|
|
@ -0,0 +1,129 @@
|
|||
#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"
|
||||
" 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")) {
|
||||
}
|
||||
}
|
|
@ -11,8 +11,7 @@
|
|||
#include <pugl/pugl.h>
|
||||
#include <limits.h>
|
||||
#include "../pui/pui.h"
|
||||
|
||||
#define TAPS 6
|
||||
#include "ptap.h"
|
||||
|
||||
/*struct PTapUI : PTextures {
|
||||
PuglView *view;
|
||||
|
@ -63,8 +62,11 @@ void PTapUI::InitWidgets()
|
|||
|
||||
int padding = 4;
|
||||
|
||||
int c_w = (widget->w - padding * 3) * 0.5f;
|
||||
int c_h = (widget->h - 25 - padding * 5) * 0.25f;
|
||||
int cols = 2;
|
||||
int rows = (NUM_TAPS + NUM_CHANNELS + cols - 1) / cols;
|
||||
|
||||
int c_w = (widget->w - padding * cols - padding) / cols;
|
||||
int c_h = (widget->h - 25 - padding * rows - padding) / rows;
|
||||
|
||||
Container *t = new Container();
|
||||
t->colour = Colour(0, 0, 0, .5f);
|
||||
|
@ -77,9 +79,9 @@ void PTapUI::InitWidgets()
|
|||
int slide_w = 25;
|
||||
// int slide_h = c_h - 25;
|
||||
|
||||
for (int i = 0; i < TAPS + 2; i++) {
|
||||
for (int i = 0; i < NUM_TAPS + NUM_CHANNELS; i++) {
|
||||
Container *c = new VBox();
|
||||
if (i < TAPS) c->frame = Colour(0, 0, 0, .15f);
|
||||
if (i < NUM_TAPS) c->frame = Colour(0, 0, 0, .15f);
|
||||
c->x = (i & 1) * (c_w + padding) + padding;
|
||||
c->y = (i >> 1) * (c_h + padding) + padding + 25;
|
||||
c->w = c_w;
|
||||
|
@ -96,22 +98,22 @@ void PTapUI::InitWidgets()
|
|||
c->Pack(c_strip);
|
||||
|
||||
Container *c_taps = new HBox();
|
||||
if (i >= TAPS) c_taps->colour = Colour(1, 1, 1, 0.15f);
|
||||
c_taps->w = slide_w * TAPS;
|
||||
if (i >= NUM_TAPS) c_taps->colour = Colour(1, 1, 1, 0.15f);
|
||||
c_taps->w = slide_w * NUM_TAPS;
|
||||
c_strip->Pack(c_taps);
|
||||
|
||||
Container *c_ins = new HBox();
|
||||
if (i >= TAPS) c_ins->colour = Colour(1, 1, 1, 0.15f);
|
||||
c_ins->w = slide_w * 2;
|
||||
if (i >= NUM_TAPS) c_ins->colour = Colour(1, 1, 1, 0.15f);
|
||||
c_ins->w = slide_w * NUM_CHANNELS;
|
||||
c_strip->Pack(c_ins);
|
||||
|
||||
if (i < TAPS) {
|
||||
if (i < NUM_TAPS) {
|
||||
snprintf(tmp, sizeof tmp, "Tap %d", i + 1);
|
||||
} else {
|
||||
strncpy(tmp, i == TAPS ? "Left Out" : "Right Out", sizeof tmp);
|
||||
strncpy(tmp, i == NUM_TAPS ? "Left Out" : "Right Out", sizeof tmp);
|
||||
}
|
||||
|
||||
for (int j = 0; j < TAPS; j++) {
|
||||
for (int j = 0; j < NUM_TAPS; j++) {
|
||||
Slider *slider = new VSlider();
|
||||
strncpy(slider->group, tmp, sizeof slider->group);
|
||||
snprintf(slider->label, sizeof slider->label, "%d", j + 1);
|
||||
|
@ -124,11 +126,11 @@ void PTapUI::InitWidgets()
|
|||
slider->w = slide_w;
|
||||
slider->min = -1.f;
|
||||
slider->max = 1.f;
|
||||
slider->port = (i * 10) + 4 + j;
|
||||
slider->port = TAP_MATRIX + i * NUM_GAINS + j;
|
||||
c_taps->Pack(slider);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int j = 0; j < NUM_CHANNELS; j++) {
|
||||
Slider *slider = new VSlider();
|
||||
strncpy(slider->group, tmp, sizeof slider->group);
|
||||
strncpy(slider->label, j == 0 ? "Left" : "Right", sizeof slider->label);
|
||||
|
@ -136,29 +138,29 @@ void PTapUI::InitWidgets()
|
|||
slider->w = slide_w;
|
||||
slider->min = -1.f;
|
||||
slider->max = 1.f;
|
||||
slider->port = (i * 10) + 4 + TAPS + j;
|
||||
slider->port = TAP_MATRIX + i * NUM_GAINS + NUM_TAPS + j;
|
||||
c_ins->Pack(slider);
|
||||
}
|
||||
|
||||
Slider *gain = new VSlider();
|
||||
strncpy(gain->group, tmp, sizeof gain->group);
|
||||
strncpy(gain->label, "Gain", sizeof gain->label);
|
||||
gain->big = i >= TAPS;
|
||||
gain->big = i >= NUM_TAPS;
|
||||
gain->colour = Colour(1, .2f, .2f, 1);
|
||||
gain->w = slide_w;
|
||||
gain->min = -1.f;
|
||||
gain->max = 1.f;
|
||||
gain->port = (i * 10) + 4 + TAPS + 2;
|
||||
gain->port = TAP_GAINS + i;
|
||||
c_strip->Pack(gain);
|
||||
|
||||
if (i < TAPS) {
|
||||
if (i < NUM_TAPS) {
|
||||
Knob *delay = new Knob();
|
||||
strncpy(delay->group, tmp, sizeof delay->group);
|
||||
strncpy(delay->label, "Delay", sizeof delay->label);
|
||||
delay->w = -1;
|
||||
delay->min = 0.f;
|
||||
delay->max = 10.f;
|
||||
delay->port = (i * 10) + 4 + TAPS + 3;
|
||||
delay->port = TAP_DELAYS + i;
|
||||
c_strip->Pack(delay);
|
||||
}
|
||||
|
||||
|
@ -221,7 +223,7 @@ static LV2UI_Handle ptapui_instantiate(
|
|||
PTapUI *pui = new PTapUI();
|
||||
pui->write = write_function;
|
||||
pui->controller = controller;
|
||||
pui->width = 700;
|
||||
pui->width = 250 + 50 * (NUM_TAPS + NUM_CHANNELS + 1);
|
||||
pui->height = 660;
|
||||
pui->exit = false;
|
||||
|
||||
|
@ -273,7 +275,7 @@ static const void *ptapui_extension_data(const char *uri)
|
|||
|
||||
static const LV2UI_Descriptor s_lv2uidescriptor =
|
||||
{
|
||||
"urn:fuzzle:ptap#X11UI",
|
||||
PTAP_URI "#X11UI",
|
||||
&ptapui_instantiate,
|
||||
&ptapui_cleanup,
|
||||
&ptapui_port_event,
|
||||
|
|
Loading…
Reference in New Issue