Add gtk ui and make pan controls work
This commit is contained in:
parent
d36035e0ab
commit
c8a7423e3e
14
Makefile
14
Makefile
@ -2,13 +2,19 @@ BUNDLE = lv2pftci-drmr.lv2
|
||||
INSTALL_DIR = /usr/local/lib/lv2
|
||||
CC=gcc
|
||||
|
||||
$(BUNDLE): manifest.ttl drmr.ttl drmr.so
|
||||
$(BUNDLE): manifest.ttl drmr.ttl drmr_ui.xml drmr.so drmr_ui.so drmr_manifest.so
|
||||
rm -rf $(BUNDLE)
|
||||
mkdir $(BUNDLE)
|
||||
cp manifest.ttl drmr.ttl drmr.so $(BUNDLE)
|
||||
cp manifest.ttl drmr.ttl drmr_ui.xml drmr.so drmr_ui.so drmr_manifest.so $(BUNDLE)
|
||||
|
||||
drmr.so: drmr.c drmr_hydrogen.c
|
||||
$(CC) -shared -fPIC -DPIC drmr.c drmr_hydrogen.c `pkg-config --cflags --libs lv2-plugin sndfile` -lexpat -lm -o drmr.so
|
||||
$(CC) -g -shared -fPIC -DPIC drmr.c drmr_hydrogen.c `pkg-config --cflags --libs lv2-plugin sndfile` -lexpat -lm -o drmr.so
|
||||
|
||||
drmr_ui.so: drmr_ui.c
|
||||
$(CC) -g -shared -fPIC -DPIC drmr_ui.c drmr_hydrogen.c `pkg-config --cflags --libs lv2-plugin gtk+-2.0 sndfile` -lexpat -lm -o drmr_ui.so
|
||||
|
||||
drmr_manifest.so: drmr_manifest.c
|
||||
$(CC) -g -shared -fPIC -DPIC drmr_manifest.c `pkg-config --cflags --libs lv2-plugin` -lexpat -lm -o drmr_manifest.so
|
||||
|
||||
install: $(BUNDLE)
|
||||
mkdir -p $(INSTALL_DIR)
|
||||
@ -16,4 +22,4 @@ install: $(BUNDLE)
|
||||
cp -R $(BUNDLE) $(INSTALL_DIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUNDLE) drmr.so
|
||||
rm -rf $(BUNDLE) drmr.so drmr_ui.so
|
38
drmr.c
38
drmr.c
@ -98,7 +98,10 @@ instantiate(const LV2_Descriptor* descriptor,
|
||||
|
||||
drmr->gains = malloc(32*sizeof(float*));
|
||||
drmr->pans = malloc(32*sizeof(float*));
|
||||
for(i = 0;i<16;i++) drmr->gains[i] = NULL;
|
||||
for(i = 0;i<32;i++) {
|
||||
drmr->gains[i] = NULL;
|
||||
drmr->pans[i] = NULL;
|
||||
}
|
||||
|
||||
return (LV2_Handle)drmr;
|
||||
}
|
||||
@ -130,11 +133,17 @@ connect_port(LV2_Handle instance,
|
||||
int goff = port_index - DRMR_GAIN_ONE;
|
||||
drmr->gains[goff] = (float*)data;
|
||||
}
|
||||
|
||||
if (port_index >= DRMR_PAN_ONE && port_index <= DRMR_PAN_THIRTYTWO) {
|
||||
int poff = port_index - DRMR_PAN_ONE;
|
||||
drmr->pans[poff] = (float*)data;
|
||||
}
|
||||
}
|
||||
|
||||
#define DB3SCALE -0.8317830986718104f
|
||||
#define DB3SCALEPO 1.8317830986718104f
|
||||
// taken from lv2 example amp plugin
|
||||
#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
|
||||
#define DB_CO(g) ((g) > GAIN_MIN ? powf(10.0f, (g) * 0.05f) : 0.0f)
|
||||
|
||||
static void run(LV2_Handle instance, uint32_t n_samples) {
|
||||
int i,kitInt;
|
||||
@ -187,24 +196,31 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
||||
int pos,lim;
|
||||
drmr_sample* cs = drmr->samples+i;
|
||||
if (cs->active) {
|
||||
float gain;
|
||||
if (i < 32)
|
||||
gain = DB_CO(*(drmr->gains[i]));
|
||||
else
|
||||
gain = DB_CO(0.0f);
|
||||
float coef_right, coef_left;
|
||||
if (i < 32) {
|
||||
float gain = DB_CO(*(drmr->gains[i]));
|
||||
float pan_right = ((*drmr->pans[i])+1)/2.0f;
|
||||
float pan_left = 1-pan_right;
|
||||
coef_right = (pan_right * (DB3SCALE * pan_right + DB3SCALEPO))*gain;
|
||||
coef_left = (pan_left * (DB3SCALE * pan_left + DB3SCALEPO))*gain;
|
||||
}
|
||||
else {
|
||||
coef_right = coef_left = 1.0f;
|
||||
}
|
||||
|
||||
if (cs->info.channels == 1) { // play mono sample
|
||||
lim = (n_samples < (cs->limit - cs->offset)?n_samples:(cs->limit-cs->offset));
|
||||
for(pos = 0;pos < lim;pos++) {
|
||||
drmr->left[pos] += cs->data[cs->offset]*gain;
|
||||
drmr->right[pos] += cs->data[cs->offset]*gain;
|
||||
drmr->left[pos] += cs->data[cs->offset]*coef_left;
|
||||
drmr->right[pos] += cs->data[cs->offset]*coef_right;
|
||||
cs->offset++;
|
||||
}
|
||||
} else { // play stereo sample
|
||||
lim = (cs->limit-cs->offset)/cs->info.channels;
|
||||
if (lim > n_samples) lim = n_samples;
|
||||
for (pos=0;pos<lim;pos++) {
|
||||
drmr->left[pos] += cs->data[cs->offset++]*gain;
|
||||
drmr->right[pos] += cs->data[cs->offset++]*gain;
|
||||
drmr->left[pos] += cs->data[cs->offset++]*coef_left;
|
||||
drmr->right[pos] += cs->data[cs->offset++]*coef_right;
|
||||
}
|
||||
}
|
||||
if (cs->offset >= cs->limit) cs->active = 0;
|
||||
|
33
drmr.h
33
drmr.h
@ -51,6 +51,7 @@ typedef struct {
|
||||
// lv2 stuff
|
||||
|
||||
#define DRMR_URI "http://github.com/nicklan/drmr"
|
||||
#define GAIN_MIN -60.0f
|
||||
|
||||
typedef enum {
|
||||
DRMR_MIDI = 0,
|
||||
@ -89,6 +90,38 @@ typedef enum {
|
||||
DRMR_GAIN_THIRTY,
|
||||
DRMR_GAIN_THIRTYONE,
|
||||
DRMR_GAIN_THIRTYTWO,
|
||||
DRMR_PAN_ONE,
|
||||
DRMR_PAN_TWO,
|
||||
DRMR_PAN_THREE,
|
||||
DRMR_PAN_FOUR,
|
||||
DRMR_PAN_FIVE,
|
||||
DRMR_PAN_SIX,
|
||||
DRMR_PAN_SEVEN,
|
||||
DRMR_PAN_EIGHT,
|
||||
DRMR_PAN_NINE,
|
||||
DRMR_PAN_TEN,
|
||||
DRMR_PAN_ELEVEN,
|
||||
DRMR_PAN_TWELVE,
|
||||
DRMR_PAN_THIRTEEN,
|
||||
DRMR_PAN_FOURTEEN,
|
||||
DRMR_PAN_FIFTEEN,
|
||||
DRMR_PAN_SIXTEEN,
|
||||
DRMR_PAN_SEVENTEEN,
|
||||
DRMR_PAN_EIGHTEEN,
|
||||
DRMR_PAN_NINETEEN,
|
||||
DRMR_PAN_TWENTY,
|
||||
DRMR_PAN_TWENTYONE,
|
||||
DRMR_PAN_TWENTYTWO,
|
||||
DRMR_PAN_TWENTYTHREE,
|
||||
DRMR_PAN_TWENTYFOUR,
|
||||
DRMR_PAN_TWENTYFIVE,
|
||||
DRMR_PAN_TWENTYSIX,
|
||||
DRMR_PAN_TWENTYSEVEN,
|
||||
DRMR_PAN_TWENTYEIGHT,
|
||||
DRMR_PAN_TWENTYNINE,
|
||||
DRMR_PAN_THIRTY,
|
||||
DRMR_PAN_THIRTYONE,
|
||||
DRMR_PAN_THIRTYTWO,
|
||||
DRMR_NUM_PORTS
|
||||
} DrMrPortIndex;
|
||||
|
||||
|
509
drmr.ttl
509
drmr.ttl
@ -54,12 +54,12 @@
|
||||
lv2:index 4;
|
||||
lv2:symbol "gain_one";
|
||||
lv2:name "Sample One Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -68,12 +68,12 @@
|
||||
lv2:index 5;
|
||||
lv2:symbol "gain_two";
|
||||
lv2:name "Sample Two Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -82,12 +82,12 @@
|
||||
lv2:index 6;
|
||||
lv2:symbol "gain_three";
|
||||
lv2:name "Sample Three Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -96,12 +96,12 @@
|
||||
lv2:index 7;
|
||||
lv2:symbol "gain_four";
|
||||
lv2:name "Sample Four Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -110,12 +110,12 @@
|
||||
lv2:index 8;
|
||||
lv2:symbol "gain_five";
|
||||
lv2:name "Sample Five Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -124,12 +124,12 @@
|
||||
lv2:index 9;
|
||||
lv2:symbol "gain_six";
|
||||
lv2:name "Sample Six Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -138,12 +138,12 @@
|
||||
lv2:index 10;
|
||||
lv2:symbol "gain_seven";
|
||||
lv2:name "Sample Seven Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -152,12 +152,12 @@
|
||||
lv2:index 11;
|
||||
lv2:symbol "gain_eight";
|
||||
lv2:name "Sample Eight Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -166,12 +166,12 @@
|
||||
lv2:index 12;
|
||||
lv2:symbol "gain_nine";
|
||||
lv2:name "Sample Nine Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -180,12 +180,12 @@
|
||||
lv2:index 13;
|
||||
lv2:symbol "gain_ten";
|
||||
lv2:name "Sample Ten Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -194,12 +194,12 @@
|
||||
lv2:index 14;
|
||||
lv2:symbol "gain_eleven";
|
||||
lv2:name "Sample Eleven Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -208,12 +208,12 @@
|
||||
lv2:index 15;
|
||||
lv2:symbol "gain_twelve";
|
||||
lv2:name "Sample Twelve Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -222,12 +222,12 @@
|
||||
lv2:index 16;
|
||||
lv2:symbol "gain_thirteen";
|
||||
lv2:name "Sample Thirteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -236,12 +236,12 @@
|
||||
lv2:index 17;
|
||||
lv2:symbol "gain_fourteen";
|
||||
lv2:name "Sample Fourteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -250,12 +250,12 @@
|
||||
lv2:index 18;
|
||||
lv2:symbol "gain_fifteen";
|
||||
lv2:name "Sample Fifteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -264,12 +264,12 @@
|
||||
lv2:index 19;
|
||||
lv2:symbol "gain_sixteen";
|
||||
lv2:name "Sample Sixteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -278,12 +278,12 @@
|
||||
lv2:index 20;
|
||||
lv2:symbol "gain_seventeen";
|
||||
lv2:name "Sample Seventeen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -293,12 +293,12 @@
|
||||
lv2:index 21;
|
||||
lv2:symbol "gain_eighteen";
|
||||
lv2:name "Sample Eighteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -307,12 +307,12 @@
|
||||
lv2:index 22;
|
||||
lv2:symbol "gain_nineteen";
|
||||
lv2:name "Sample Nineteen Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -321,12 +321,12 @@
|
||||
lv2:index 23;
|
||||
lv2:symbol "gain_twenty";
|
||||
lv2:name "Sample Twenty Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -335,12 +335,12 @@
|
||||
lv2:index 24;
|
||||
lv2:symbol "gain_twentyone";
|
||||
lv2:name "Sample Twenty One Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -349,12 +349,12 @@
|
||||
lv2:index 25;
|
||||
lv2:symbol "gain_twentytwo";
|
||||
lv2:name "Sample Twenty Two Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -363,12 +363,12 @@
|
||||
lv2:index 26;
|
||||
lv2:symbol "gain_twentythree";
|
||||
lv2:name "Sample Twenty Three Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -377,12 +377,12 @@
|
||||
lv2:index 27;
|
||||
lv2:symbol "gain_twentyfour";
|
||||
lv2:name "Sample Twenty Four Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -391,12 +391,12 @@
|
||||
lv2:index 28;
|
||||
lv2:symbol "gain_twentyfive";
|
||||
lv2:name "Sample Twenty Five Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -405,12 +405,12 @@
|
||||
lv2:index 29;
|
||||
lv2:symbol "gain_twentysix";
|
||||
lv2:name "Sample Twenty Six Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -419,12 +419,12 @@
|
||||
lv2:index 30;
|
||||
lv2:symbol "gain_twentyseven";
|
||||
lv2:name "Sample Twenty Seven Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -433,12 +433,12 @@
|
||||
lv2:index 31;
|
||||
lv2:symbol "gain_twentyeight";
|
||||
lv2:name "Sample Twenty Eight Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -447,12 +447,12 @@
|
||||
lv2:index 32;
|
||||
lv2:symbol "gain_twentynine";
|
||||
lv2:name "Sample Twenty Nine Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -461,12 +461,12 @@
|
||||
lv2:index 33;
|
||||
lv2:symbol "gain_thirty";
|
||||
lv2:name "Sample Thirty Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -475,12 +475,12 @@
|
||||
lv2:index 34;
|
||||
lv2:symbol "gain_thirtyone";
|
||||
lv2:name "Sample Thirty One Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
@ -489,13 +489,394 @@
|
||||
lv2:index 35;
|
||||
lv2:symbol "gain_thirtytwo";
|
||||
lv2:name "Sample Thirty Two Gain";
|
||||
lv2:minimum -90.0;
|
||||
lv2:minimum -60.0;
|
||||
lv2:maximum 6.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -90.0
|
||||
rdf:value -60.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 36;
|
||||
lv2:symbol "pan_one";
|
||||
lv2:name "Sample One Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 37;
|
||||
lv2:symbol "pan_two";
|
||||
lv2:name "Sample Two Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 38;
|
||||
lv2:symbol "pan_three";
|
||||
lv2:name "Sample Three Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 39;
|
||||
lv2:symbol "pan_four";
|
||||
lv2:name "Sample Four Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 40;
|
||||
lv2:symbol "pan_five";
|
||||
lv2:name "Sample Five Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 41;
|
||||
lv2:symbol "pan_six";
|
||||
lv2:name "Sample Six Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 42;
|
||||
lv2:symbol "pan_seven";
|
||||
lv2:name "Sample Seven Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 43;
|
||||
lv2:symbol "pan_eight";
|
||||
lv2:name "Sample Eight Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 44;
|
||||
lv2:symbol "pan_nine";
|
||||
lv2:name "Sample Nine Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 45;
|
||||
lv2:symbol "pan_ten";
|
||||
lv2:name "Sample Ten Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 46;
|
||||
lv2:symbol "pan_eleven";
|
||||
lv2:name "Sample Eleven Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 47;
|
||||
lv2:symbol "pan_twelve";
|
||||
lv2:name "Sample Twelve Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 48;
|
||||
lv2:symbol "pan_thirteen";
|
||||
lv2:name "Sample Thirteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 49;
|
||||
lv2:symbol "pan_fourteen";
|
||||
lv2:name "Sample Fourteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 50;
|
||||
lv2:symbol "pan_fifteen";
|
||||
lv2:name "Sample Fifteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 51;
|
||||
lv2:symbol "pan_sixteen";
|
||||
lv2:name "Sample Sixteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 52;
|
||||
lv2:symbol "pan_seventeen";
|
||||
lv2:name "Sample Seventeen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 53;
|
||||
lv2:symbol "pan_eighteen";
|
||||
lv2:name "Sample Eighteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 54;
|
||||
lv2:symbol "pan_nineteen";
|
||||
lv2:name "Sample Nineteen Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 55;
|
||||
lv2:symbol "pan_twenty";
|
||||
lv2:name "Sample Twenty Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 56;
|
||||
lv2:symbol "pan_twentyone";
|
||||
lv2:name "Sample Twenty One Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 57;
|
||||
lv2:symbol "pan_twentytwo";
|
||||
lv2:name "Sample Twenty Two Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 58;
|
||||
lv2:symbol "pan_twentythree";
|
||||
lv2:name "Sample Twenty Three Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 59;
|
||||
lv2:symbol "pan_twentyfour";
|
||||
lv2:name "Sample Twenty Four Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 60;
|
||||
lv2:symbol "pan_twentyfive";
|
||||
lv2:name "Sample Twenty Five Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 61;
|
||||
lv2:symbol "pan_twentysix";
|
||||
lv2:name "Sample Twenty Six Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 62;
|
||||
lv2:symbol "pan_twentyseven";
|
||||
lv2:name "Sample Twenty Seven Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 63;
|
||||
lv2:symbol "pan_twentyeight";
|
||||
lv2:name "Sample Twenty Eight Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 64;
|
||||
lv2:symbol "pan_twentynine";
|
||||
lv2:name "Sample Twenty Nine Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 65;
|
||||
lv2:symbol "pan_thirty";
|
||||
lv2:name "Sample Thirty Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 66;
|
||||
lv2:symbol "pan_thirtyone";
|
||||
lv2:name "Sample Thirty One Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
lv2:scalePoint [
|
||||
rdfs:label "-inf" ;
|
||||
rdf:value -1.0
|
||||
]
|
||||
],
|
||||
|
||||
[
|
||||
a lv2:ControlPort, lv2:InputPort;
|
||||
lv2:index 67;
|
||||
lv2:symbol "pan_thirtytwo";
|
||||
lv2:name "Sample Thirty Two Pan";
|
||||
lv2:minimum -1.0;
|
||||
lv2:maximum 1.0;
|
||||
lv2:default 0.0;
|
||||
].
|
||||
|
||||
<http://github.com/nicklan/drmr#ui>
|
||||
|
@ -47,6 +47,7 @@ struct instrument_info {
|
||||
struct kit_info {
|
||||
char* name;
|
||||
char* desc;
|
||||
int inst_count;
|
||||
// linked list of intruments, null terminated
|
||||
struct instrument_info* instruments;
|
||||
};
|
||||
@ -99,15 +100,20 @@ endElement(void *userData, const char *name)
|
||||
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
|
||||
info->kit_info->desc = strdup(info->cur_buf);
|
||||
|
||||
if (!info->scan_only && info->in_instrument) {
|
||||
if (!strcmp(name,"id"))
|
||||
info->cur_instrument->id = atoi(info->cur_buf);
|
||||
if (!strcmp(name,"filename"))
|
||||
info->cur_instrument->filename = strdup(info->cur_buf);
|
||||
if (!strcmp(name,"name"))
|
||||
info->cur_instrument->name = strdup(info->cur_buf);
|
||||
if (info->in_instrument) {
|
||||
if (info->scan_only) {
|
||||
if (!strcmp(name,"filename"))
|
||||
info->kit_info->inst_count++;
|
||||
}
|
||||
else {
|
||||
if (!strcmp(name,"id"))
|
||||
info->cur_instrument->id = atoi(info->cur_buf);
|
||||
if (!strcmp(name,"filename"))
|
||||
info->cur_instrument->filename = strdup(info->cur_buf);
|
||||
if (!strcmp(name,"name"))
|
||||
info->cur_instrument->name = strdup(info->cur_buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
info->cur_off = 0;
|
||||
|
||||
@ -202,6 +208,7 @@ kits* scan_kits() {
|
||||
memset(node,0,sizeof(struct kit_list));
|
||||
kit->name = info.kit_info->name;
|
||||
kit->desc = info.kit_info->desc;
|
||||
kit->samples = info.kit_info->inst_count;
|
||||
snprintf(buf,BUFSIZ,"%s/%s/",cur_path,ep->d_name);
|
||||
kit->path = strdup(buf);
|
||||
node->skit = kit;
|
||||
@ -239,6 +246,7 @@ kits* scan_kits() {
|
||||
ret->kits[cp].name = cur_k->skit->name;
|
||||
ret->kits[cp].desc = cur_k->skit->desc;
|
||||
ret->kits[cp].path = cur_k->skit->path;
|
||||
ret->kits[cp].samples = cur_k->skit->samples;
|
||||
cp++;
|
||||
free(cur_k->skit);
|
||||
cur_k = cur_k->next;
|
||||
|
276
drmr_ui.c
Normal file
276
drmr_ui.c
Normal file
@ -0,0 +1,276 @@
|
||||
/* drmr.c
|
||||
* LV2 DrMr plugin
|
||||
* Copyright 2012 Nick Lanham <nick@afternight.org>
|
||||
*
|
||||
* Public License v3. source code is available at
|
||||
* <http://github.com/nicklan/drmr>
|
||||
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "drmr.h"
|
||||
#include "drmr_hydrogen.h"
|
||||
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
|
||||
|
||||
#define DRMR_UI_URI "http://github.com/nicklan/drmr#ui"
|
||||
|
||||
typedef struct {
|
||||
LV2UI_Write_Function write;
|
||||
LV2UI_Controller controller;
|
||||
|
||||
GtkWidget *drmr_widget;
|
||||
GtkTable *sample_table;
|
||||
GtkComboBoxText *kit_combo;
|
||||
GtkWidget** gain_sliders;
|
||||
GtkWidget** pan_sliders;
|
||||
int cols;
|
||||
|
||||
GQuark gain_quark, pan_quark;
|
||||
|
||||
kits* kits;
|
||||
} DrMrUi;
|
||||
|
||||
static void gain_callback(GtkRange* range, gpointer data) {
|
||||
DrMrUi* ui = (DrMrUi*)data;
|
||||
int gidx = GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(range),ui->gain_quark));
|
||||
float gain = gtk_range_get_value(range);
|
||||
ui->write(ui->controller,gidx+DRMR_GAIN_ONE,4,0,&gain);
|
||||
}
|
||||
|
||||
static void pan_callback(GtkRange* range, gpointer data) {
|
||||
DrMrUi* ui = (DrMrUi*)data;
|
||||
int pidx = GPOINTER_TO_INT(g_object_get_qdata(G_OBJECT(range),ui->pan_quark));
|
||||
float pan = gtk_range_get_value(range);
|
||||
ui->write(ui->controller,pidx+DRMR_PAN_ONE,4,0,&pan);
|
||||
}
|
||||
|
||||
static void fill_sample_table(DrMrUi* ui, int samples) {
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
int si;
|
||||
gchar buf[32];;
|
||||
GtkRequisition req;
|
||||
int rows = (samples/ui->cols);
|
||||
req.width=500;
|
||||
req.height=500;
|
||||
gtk_table_resize(ui->sample_table,rows,ui->cols);
|
||||
for(si = 0;si<samples;si++) {
|
||||
GtkWidget *frame,*hbox,*gain_vbox,*pan_vbox;
|
||||
GtkWidget* gain_slider;
|
||||
GtkWidget* pan_slider;
|
||||
GtkWidget* gain_label;
|
||||
GtkWidget* pan_label;
|
||||
sprintf(buf,"<b>Sample %i</b>",si);
|
||||
|
||||
frame = gtk_frame_new(buf);
|
||||
gtk_label_set_use_markup(GTK_LABEL(gtk_frame_get_label_widget(GTK_FRAME(frame))),true);
|
||||
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
|
||||
hbox = gtk_hbox_new(false,0);
|
||||
|
||||
gain_slider = gtk_vscale_new_with_range(GAIN_MIN,6.0,1.0);
|
||||
g_object_set_qdata (G_OBJECT(gain_slider),ui->gain_quark,GINT_TO_POINTER(si));
|
||||
g_signal_connect(G_OBJECT(gain_slider),"value-changed",G_CALLBACK(gain_callback),ui);
|
||||
if (ui->gain_sliders)
|
||||
ui->gain_sliders[si] = gain_slider;
|
||||
gtk_range_set_inverted(GTK_RANGE(gain_slider),true);
|
||||
gtk_scale_set_value_pos(GTK_SCALE(gain_slider),GTK_POS_BOTTOM);
|
||||
gtk_range_set_value(GTK_RANGE(gain_slider),0.0);
|
||||
gtk_scale_set_digits(GTK_SCALE(gain_slider),1);
|
||||
gtk_scale_add_mark(GTK_SCALE(gain_slider),0.0,GTK_POS_RIGHT,"0 dB");
|
||||
// Hrmm, -inf label is at top in ardour for some reason
|
||||
//gtk_scale_add_mark(GTK_SCALE(gain_slider),GAIN_MIN,GTK_POS_RIGHT,"-inf");
|
||||
gain_label = gtk_label_new("Gain");
|
||||
gain_vbox = gtk_vbox_new(false,0);
|
||||
|
||||
pan_slider = gtk_hscale_new_with_range(-1.0,1.0,0.1);
|
||||
if (ui->pan_sliders)
|
||||
ui->pan_sliders[si] = pan_slider;
|
||||
gtk_range_set_value(GTK_RANGE(pan_slider),0);
|
||||
g_object_set_qdata (G_OBJECT(pan_slider),ui->pan_quark,GINT_TO_POINTER(si));
|
||||
gtk_scale_add_mark(GTK_SCALE(pan_slider),0.0,GTK_POS_TOP,NULL);
|
||||
g_signal_connect(G_OBJECT(pan_slider),"value-changed",G_CALLBACK(pan_callback),ui);
|
||||
pan_label = gtk_label_new("Pan");
|
||||
pan_vbox = gtk_vbox_new(false,0);
|
||||
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(gain_vbox),gain_slider,true,true,0);
|
||||
gtk_box_pack_start(GTK_BOX(gain_vbox),gain_label,false,false,0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(pan_vbox),pan_slider,true,true,0);
|
||||
gtk_box_pack_start(GTK_BOX(pan_vbox),pan_label,false,false,0);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(hbox),gain_vbox,true,true,0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),pan_vbox,true,true,0);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(frame),hbox);
|
||||
|
||||
gtk_widget_size_request(frame,&req);
|
||||
|
||||
gtk_table_attach_defaults(ui->sample_table,frame,col,col+1,row,row+1);
|
||||
|
||||
col++;
|
||||
if (col >= ui->cols) {
|
||||
col = 0;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void kit_combobox_changed(GtkComboBox* box, gpointer data) {
|
||||
gint new_kit = gtk_combo_box_get_active (GTK_COMBO_BOX(box));
|
||||
printf("kit changed: %i\n",new_kit);
|
||||
}
|
||||
|
||||
static void fill_kit_combo(GtkComboBoxText* combo, kits* kits) {
|
||||
int i;
|
||||
for (i=0;i<kits->num_kits;i++)
|
||||
gtk_combo_box_text_append_text(combo,kits->kits[i].name);
|
||||
}
|
||||
|
||||
static void build_drmr_ui(DrMrUi* ui) {
|
||||
GtkWidget *drmr_ui_widget;
|
||||
GtkWidget *sample_table;
|
||||
GtkWidget *kit_hbox, *kit_combo_box, *kit_label;
|
||||
|
||||
drmr_ui_widget = gtk_vbox_new(false,0);
|
||||
g_object_set(drmr_ui_widget,"border-width",6,NULL);
|
||||
|
||||
sample_table = gtk_table_new(1,1,true);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(sample_table),5);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(sample_table),5);
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),sample_table,
|
||||
true,true,5);
|
||||
|
||||
kit_hbox = gtk_hbox_new(false,0);
|
||||
kit_combo_box = gtk_combo_box_text_new();
|
||||
kit_label = gtk_label_new("Kit:");
|
||||
|
||||
gtk_box_pack_start(GTK_BOX(kit_hbox),kit_label,
|
||||
false,false,15);
|
||||
gtk_box_pack_start(GTK_BOX(kit_hbox),kit_combo_box,
|
||||
true,true,0);
|
||||
gtk_box_pack_start(GTK_BOX(drmr_ui_widget),kit_hbox,
|
||||
false,false,5);
|
||||
|
||||
ui->drmr_widget = drmr_ui_widget;
|
||||
ui->sample_table = GTK_TABLE(sample_table);
|
||||
ui->kit_combo = GTK_COMBO_BOX_TEXT(kit_combo_box);
|
||||
|
||||
g_signal_connect(G_OBJECT(kit_combo_box),"changed",G_CALLBACK(kit_combobox_changed),NULL);
|
||||
|
||||
gtk_widget_show_all(drmr_ui_widget);
|
||||
}
|
||||
|
||||
static LV2UI_Handle
|
||||
instantiate(const LV2UI_Descriptor* descriptor,
|
||||
const char* plugin_uri,
|
||||
const char* bundle_path,
|
||||
LV2UI_Write_Function write_function,
|
||||
LV2UI_Controller controller,
|
||||
LV2UI_Widget* widget,
|
||||
const LV2_Feature* const* features) {
|
||||
DrMrUi *ui = (DrMrUi*)malloc(sizeof(DrMrUi));
|
||||
int i;
|
||||
|
||||
ui->write = write_function;
|
||||
ui->controller = controller;
|
||||
ui->drmr_widget = NULL;
|
||||
*widget = NULL;
|
||||
|
||||
build_drmr_ui(ui);
|
||||
|
||||
ui->kits = scan_kits();
|
||||
ui->gain_quark = g_quark_from_string("drmr_gain_quark");
|
||||
ui->pan_quark = g_quark_from_string("drmr_pan_quark");
|
||||
ui->gain_sliders = NULL;
|
||||
ui->pan_sliders = NULL;
|
||||
ui->cols = 4;
|
||||
fill_kit_combo(ui->kit_combo, ui->kits);
|
||||
|
||||
*widget = ui->drmr_widget;
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
|
||||
static void cleanup(LV2UI_Handle handle) {
|
||||
DrMrUi* ui = (DrMrUi*)handle;
|
||||
gtk_widget_destroy(ui->drmr_widget);
|
||||
free(ui);
|
||||
}
|
||||
|
||||
static void
|
||||
port_event(LV2UI_Handle handle,
|
||||
uint32_t port_index,
|
||||
uint32_t buffer_size,
|
||||
uint32_t format,
|
||||
const void* buffer) {
|
||||
DrMrPortIndex index = (DrMrPortIndex)port_index;
|
||||
DrMrUi* ui = (DrMrUi*)handle;
|
||||
|
||||
if (index == DRMR_KITNUM) {
|
||||
if (format != 0)
|
||||
fprintf(stderr,"Invalid format for kitnum: %i\n",format);
|
||||
else {
|
||||
int kit = (int)(*((float*)buffer));
|
||||
int samples = ui->kits->kits[kit].samples;
|
||||
ui->gain_sliders = malloc(samples*sizeof(GtkWidget*));
|
||||
ui->pan_sliders = malloc(samples*sizeof(GtkWidget*));
|
||||
fill_sample_table(ui,samples);
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX(ui->kit_combo), kit);
|
||||
gtk_widget_show_all(GTK_WIDGET(ui->sample_table));
|
||||
}
|
||||
}
|
||||
else if (index >= DRMR_GAIN_ONE &&
|
||||
index <= DRMR_GAIN_SIXTEEN) {
|
||||
if (ui->gain_sliders) {
|
||||
float gain = *(float*)buffer;
|
||||
GtkRange* range = GTK_RANGE(ui->gain_sliders[index-DRMR_GAIN_ONE]);
|
||||
gtk_range_set_value(range,gain);
|
||||
}
|
||||
}
|
||||
else if (index >= DRMR_PAN_ONE &&
|
||||
index <= DRMR_PAN_SIXTEEN) {
|
||||
if (ui->pan_sliders) {
|
||||
float pan = *(float*)buffer;
|
||||
GtkRange* range = GTK_RANGE(ui->pan_sliders[index-DRMR_PAN_ONE]);
|
||||
gtk_range_set_value(range,pan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const void*
|
||||
extension_data(const char* uri) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const LV2UI_Descriptor descriptor = {
|
||||
DRMR_UI_URI,
|
||||
instantiate,
|
||||
cleanup,
|
||||
port_event,
|
||||
extension_data
|
||||
};
|
||||
|
||||
LV2_SYMBOL_EXPORT
|
||||
const LV2UI_Descriptor*
|
||||
lv2ui_descriptor(uint32_t index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return &descriptor;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user