Fix gain calculation

This commit is contained in:
Nick Lanham 2012-02-12 13:33:38 +01:00
parent 8ed58ec1c6
commit ba2b776b0b
2 changed files with 113 additions and 51 deletions

10
drmr.c
View File

@ -175,6 +175,8 @@ connect_port(LV2_Handle instance,
static void activate(LV2_Handle instance) { }
// taken from lv2 example amp plugin
#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
static void run(LV2_Handle instance, uint32_t n_samples) {
int i,kitInt;
@ -185,7 +187,7 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
pthread_cond_signal(&drmr->load_cond);
LV2_Event_Iterator eit;
if (lv2_event_begin(&eit,drmr->midi_port)) { // if we have any events
if (drmr->midi_port && lv2_event_begin(&eit,drmr->midi_port)) { // if we have any events
LV2_Event *cur_ev;
uint8_t* data;
while (lv2_event_is_valid(&eit)) {
@ -229,9 +231,9 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
if (cs->active) {
float gain;
if (i < 16)
gain = *(drmr->gains[i]);
gain = DB_CO(*(drmr->gains[i]));
else
gain = 1.0f;
gain = DB_CO(0.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++) {
@ -265,7 +267,7 @@ static void cleanup(LV2_Handle instance) {
free(instance);
}
const void* extension_data(const char* uri) {
static const void* extension_data(const char* uri) {
return NULL;
}

154
drmr.ttl
View File

@ -52,9 +52,13 @@
lv2:index 4;
lv2:symbol "gain_one";
lv2:name "Sample One Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -62,9 +66,13 @@
lv2:index 5;
lv2:symbol "gain_two";
lv2:name "Sample Two Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -72,9 +80,13 @@
lv2:index 6;
lv2:symbol "gain_three";
lv2:name "Sample Three Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -82,9 +94,13 @@
lv2:index 7;
lv2:symbol "gain_four";
lv2:name "Sample Four Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -92,19 +108,27 @@
lv2:index 8;
lv2:symbol "gain_five";
lv2:name "Sample Five Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
a lv2:ControlPort, lv2:InputPort;
lv2:index 9;
lv2:symbol "gain_siz";
lv2:name "Sample Siz Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:symbol "gain_six";
lv2:name "Sample Six Gain";
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -112,9 +136,13 @@
lv2:index 10;
lv2:symbol "gain_seven";
lv2:name "Sample Seven Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -122,9 +150,13 @@
lv2:index 11;
lv2:symbol "gain_eight";
lv2:name "Sample Eight Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -132,9 +164,13 @@
lv2:index 12;
lv2:symbol "gain_nine";
lv2:name "Sample Nine Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -142,9 +178,13 @@
lv2:index 13;
lv2:symbol "gain_ten";
lv2:name "Sample Ten Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -152,9 +192,13 @@
lv2:index 14;
lv2:symbol "gain_eleven";
lv2:name "Sample Eleven Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -162,9 +206,13 @@
lv2:index 15;
lv2:symbol "gain_twelve";
lv2:name "Sample Twelve Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -172,9 +220,13 @@
lv2:index 16;
lv2:symbol "gain_thirteen";
lv2:name "Sample Thirteen Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -182,9 +234,13 @@
lv2:index 17;
lv2:symbol "gain_fourteen";
lv2:name "Sample Fourteen Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[
@ -192,9 +248,13 @@
lv2:index 18;
lv2:symbol "gain_fifteen";
lv2:name "Sample Fifteen Gain";
lv2:minimum 0.0;
lv2:maximum 1.0;
lv2:default 1.0;
lv2:minimum -90.0;
lv2:maximum 6.0;
lv2:default 0.0;
lv2:scalePoint [
rdfs:label "-inf" ;
rdf:value -90.0
]
],
[