Skip to content

Commit

Permalink
Add ignore vel and note_off ports
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklan committed Apr 2, 2012
1 parent 61acaf2 commit 6c1544e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
22 changes: 17 additions & 5 deletions drmr.c
Expand Up @@ -142,6 +142,13 @@ connect_port(LV2_Handle instance,
break;
case DRMR_BASENOTE:
if (data) drmr->baseNote = (float*)data;
break;
case DRMR_IGNORE_VELOCITY:
if (data) drmr->ignore_velocity = (float*)data;
break;
case DRMR_IGNORE_NOTE_OFF:
if (data) drmr->ignore_note_off = (float*)data;
break;
default:
break;
}
Expand Down Expand Up @@ -182,6 +189,7 @@ static inline void layer_to_sample(drmr_sample *sample, float gain) {
static inline void trigger_sample(DrMr *drmr, int nn, uint8_t* const data) {
// need to mutex this to avoid getting the samples array
// changed after the check that the midi-note is valid
int ignvel = (int)floorf(*(drmr->ignore_velocity));
pthread_mutex_lock(&drmr->load_mutex);
if (nn >= 0 && nn < drmr->num_samples) {
if (drmr->samples[nn].layer_count > 0) {
Expand All @@ -191,7 +199,7 @@ static inline void trigger_sample(DrMr *drmr, int nn, uint8_t* const data) {
}
drmr->samples[nn].active = 1;
drmr->samples[nn].offset = 0;
drmr->samples[nn].velocity = ((float)data[2])/VELOCITY_MAX;
drmr->samples[nn].velocity = ignvel?1.0:((float)data[2])/VELOCITY_MAX;
}
pthread_mutex_unlock(&drmr->load_mutex);
}
Expand All @@ -216,11 +224,13 @@ static inline void untrigger_sample(DrMr *drmr, int nn) {
#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,baseNote;
int i,kitInt,baseNote,ignno;
DrMr* drmr = (DrMr*)instance;

kitInt = (int)floorf(*(drmr->kitReq));
baseNote = (int)floorf(*(drmr->baseNote));
ignno = (int)floorf(*(drmr->ignore_note_off));

if (kitInt != drmr->curKit) // requested a new kit
pthread_cond_signal(&drmr->load_cond);

Expand All @@ -235,9 +245,11 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
//int channel = *data & 15;
switch ((*data) >> 4) {
case 8:
nn = data[1];
nn-=baseNote;
untrigger_sample(drmr,nn);
if (!ignno) {
nn = data[1];
nn-=baseNote;
untrigger_sample(drmr,nn);
}
break;
case 9: {
nn = data[1];
Expand Down
4 changes: 4 additions & 0 deletions drmr.h
Expand Up @@ -137,6 +137,8 @@ typedef enum {
DRMR_PAN_THIRTY,
DRMR_PAN_THIRTYONE,
DRMR_PAN_THIRTYTWO,
DRMR_IGNORE_VELOCITY,
DRMR_IGNORE_NOTE_OFF,
DRMR_NUM_PORTS
} DrMrPortIndex;

Expand All @@ -151,6 +153,8 @@ typedef struct {
float** pans;
float* kitReq;
float* baseNote;
float* ignore_velocity;
float* ignore_note_off;
double rate;

// URIs
Expand Down
28 changes: 27 additions & 1 deletion drmr.ttl
Expand Up @@ -4,6 +4,7 @@
@prefix doap: <http://usefulinc.com/ns/doap#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix epp: <http://lv2plug.in/ns/dev/extportinfo#> .
@prefix ui: <http://lv2plug.in/ns/extensions/ui#>.

<http://github.com/nicklan/drmr>
Expand Down Expand Up @@ -889,7 +890,32 @@
lv2:minimum -1.0;
lv2:maximum 1.0;
lv2:default 0.0;
].
],

[
a lv2:ControlPort, lv2:InputPort ;
lv2:index 69;
lv2:symbol "ignore_velocity" ;
lv2:name "Ignore Velocity" ;
lv2:portProperty epp:hasStrictBounds ;
lv2:portProperty lv2:toggled ;
lv2:default 0.00000 ;
lv2:minimum 0.00000 ;
lv2:maximum 1.00000 ;
],

[
a lv2:ControlPort, lv2:InputPort ;
lv2:index 70;
lv2:symbol "ignore_note_off" ;
lv2:name "Ignore Note Off" ;
lv2:portProperty epp:hasStrictBounds ;
lv2:portProperty lv2:toggled ;
lv2:default 0.00000 ;
lv2:minimum 1.00000 ;
lv2:maximum 1.00000 ;
]
.

<http://github.com/nicklan/drmr#ui>
a ui:GtkUI ;
Expand Down

0 comments on commit 6c1544e

Please sign in to comment.