Move to using atom instead of event. So far just pass midi via atom.
This commit is contained in:
parent
1a624dd489
commit
990caaf510
@ -51,8 +51,15 @@ target_link_libraries(drmr_ui ${LV2_LIBRARIES} ${GTK2_LIBRARIES} ${SNDFILE_LIBRA
|
|||||||
|
|
||||||
add_definitions ( -DPIC )
|
add_definitions ( -DPIC )
|
||||||
|
|
||||||
|
set_target_properties (drmr
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_FLAGS "-std=gnu99"
|
||||||
|
)
|
||||||
|
|
||||||
|
set (ui_compile_flags "-std=gnu99")
|
||||||
|
|
||||||
if (NOT USE_NKNOB)
|
if (NOT USE_NKNOB)
|
||||||
set (ui_compile_flags "-DNO_NKNOB")
|
set (ui_compile_flags "${ui_compile_flags} -DNO_NKNOB")
|
||||||
endif (NOT USE_NKNOB)
|
endif (NOT USE_NKNOB)
|
||||||
|
|
||||||
if (SAMP_ZERO_POS GREATER "-1" AND SAMP_ZERO_POS LESS "4")
|
if (SAMP_ZERO_POS GREATER "-1" AND SAMP_ZERO_POS LESS "4")
|
||||||
|
80
drmr.c
80
drmr.c
@ -81,17 +81,16 @@ instantiate(const LV2_Descriptor* descriptor,
|
|||||||
|
|
||||||
// Map midi uri
|
// Map midi uri
|
||||||
while(*features) {
|
while(*features) {
|
||||||
if (!strcmp((*features)->URI, LV2_URI_MAP_URI)) {
|
if (!strcmp((*features)->URI, LV2_URID_URI "#map")) {
|
||||||
drmr->map = (LV2_URI_Map_Feature *)((*features)->data);
|
drmr->map = (LV2_URID_Map *)((*features)->data);
|
||||||
drmr->uris.midi_event = drmr->map->uri_to_id
|
drmr->uris.midi_event =
|
||||||
(drmr->map->callback_data,
|
drmr->map->map(drmr->map->handle,
|
||||||
"http://lv2plug.in/ns/ext/event",
|
"http://lv2plug.in/ns/ext/midi#MidiEvent");
|
||||||
"http://lv2plug.in/ns/ext/midi#MidiEvent");
|
|
||||||
}
|
}
|
||||||
features++;
|
features++;
|
||||||
}
|
}
|
||||||
if (!drmr->map) {
|
if (!drmr->map) {
|
||||||
fprintf(stderr, "LV2 host does not support uri-map.\n");
|
fprintf(stderr, "LV2 host does not support urid#map.\n");
|
||||||
free(drmr);
|
free(drmr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -126,8 +125,8 @@ connect_port(LV2_Handle instance,
|
|||||||
DrMr* drmr = (DrMr*)instance;
|
DrMr* drmr = (DrMr*)instance;
|
||||||
DrMrPortIndex port_index = (DrMrPortIndex)port;
|
DrMrPortIndex port_index = (DrMrPortIndex)port;
|
||||||
switch (port_index) {
|
switch (port_index) {
|
||||||
case DRMR_MIDI:
|
case DRMR_CONTROL:
|
||||||
drmr->midi_port = (LV2_Event_Buffer*)data;
|
drmr->control_port = (LV2_Atom_Sequence*)data;
|
||||||
break;
|
break;
|
||||||
case DRMR_LEFT:
|
case DRMR_LEFT:
|
||||||
drmr->left = (float*)data;
|
drmr->left = (float*)data;
|
||||||
@ -191,42 +190,37 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
|||||||
if (kitInt != drmr->curKit) // requested a new kit
|
if (kitInt != drmr->curKit) // requested a new kit
|
||||||
pthread_cond_signal(&drmr->load_cond);
|
pthread_cond_signal(&drmr->load_cond);
|
||||||
|
|
||||||
LV2_Event_Iterator eit;
|
LV2_SEQUENCE_FOREACH(drmr->control_port, i) {
|
||||||
if (drmr->midi_port && lv2_event_begin(&eit,drmr->midi_port)) { // if we have any events
|
LV2_Atom_Event* const ev = lv2_sequence_iter_get(i);
|
||||||
LV2_Event *cur_ev;
|
if (ev->body.type == drmr->uris.midi_event) {
|
||||||
uint8_t* data;
|
uint8_t* const data = (uint8_t* const)(ev + 1);
|
||||||
while (lv2_event_is_valid(&eit)) {
|
//int channel = *data & 15;
|
||||||
cur_ev = lv2_event_get(&eit,&data);
|
switch ((*data) >> 4) {
|
||||||
if (cur_ev->type == drmr->uris.midi_event) {
|
case 8: // ignore note-offs for now, should probably be a setting
|
||||||
//int channel = *data & 15;
|
//if (drmr->cur_samp) drmr->cur_samp->active = 0;
|
||||||
switch ((*data) >> 4) {
|
break;
|
||||||
case 8: // ignore note-offs for now, should probably be a setting
|
case 9: {
|
||||||
//if (drmr->cur_samp) drmr->cur_samp->active = 0;
|
uint8_t nn = data[1];
|
||||||
break;
|
nn-=baseNote;
|
||||||
case 9: {
|
// need to mutex this to avoid getting the samples array
|
||||||
uint8_t nn = data[1];
|
// changed after the check that the midi-note is valid
|
||||||
nn-=baseNote;
|
pthread_mutex_lock(&drmr->load_mutex);
|
||||||
// need to mutex this to avoid getting the samples array
|
if (nn >= 0 && nn < drmr->num_samples) {
|
||||||
// changed after the check that the midi-note is valid
|
if (drmr->samples[nn].layer_count > 0) {
|
||||||
pthread_mutex_lock(&drmr->load_mutex);
|
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
|
||||||
if (nn >= 0 && nn < drmr->num_samples) {
|
if (drmr->samples[nn].limit == 0)
|
||||||
if (drmr->samples[nn].layer_count > 0) {
|
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
|
||||||
layer_to_sample(drmr->samples+nn,*(drmr->gains[nn]));
|
|
||||||
if (drmr->samples[nn].limit == 0)
|
|
||||||
fprintf(stderr,"Failed to find layer at: %i for %f\n",nn,*drmr->gains[nn]);
|
|
||||||
}
|
|
||||||
drmr->samples[nn].active = 1;
|
|
||||||
drmr->samples[nn].offset = 0;
|
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&drmr->load_mutex);
|
drmr->samples[nn].active = 1;
|
||||||
break;
|
drmr->samples[nn].offset = 0;
|
||||||
}
|
}
|
||||||
default:
|
pthread_mutex_unlock(&drmr->load_mutex);
|
||||||
printf("Unhandeled status: %i\n",(*data)>>4);
|
break;
|
||||||
}
|
}
|
||||||
} else printf("unrecognized event\n");
|
default:
|
||||||
lv2_event_increment(&eit);
|
printf("Unhandeled status: %i\n",(*data)>>4);
|
||||||
}
|
}
|
||||||
|
} else printf("unrecognized event\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0;i<n_samples;i++) {
|
for(i = 0;i<n_samples;i++) {
|
||||||
|
15
drmr.h
15
drmr.h
@ -20,10 +20,11 @@
|
|||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
|
||||||
|
// util includes atom.h
|
||||||
|
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
|
||||||
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
|
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
|
||||||
#include "lv2/lv2plug.in/ns/ext/event/event.h"
|
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
|
||||||
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
|
|
||||||
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
|
|
||||||
|
|
||||||
// drumkit scanned from a hydrogen xml file
|
// drumkit scanned from a hydrogen xml file
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -67,7 +68,7 @@ typedef struct {
|
|||||||
#define GAIN_MAX 6.0f
|
#define GAIN_MAX 6.0f
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
DRMR_MIDI = 0,
|
DRMR_CONTROL = 0,
|
||||||
DRMR_LEFT,
|
DRMR_LEFT,
|
||||||
DRMR_RIGHT,
|
DRMR_RIGHT,
|
||||||
DRMR_KITNUM,
|
DRMR_KITNUM,
|
||||||
@ -143,7 +144,7 @@ typedef struct {
|
|||||||
// Ports
|
// Ports
|
||||||
float* left;
|
float* left;
|
||||||
float* right;
|
float* right;
|
||||||
LV2_Event_Buffer *midi_port;
|
LV2_Atom_Sequence *control_port;
|
||||||
|
|
||||||
// params
|
// params
|
||||||
float** gains;
|
float** gains;
|
||||||
@ -153,9 +154,9 @@ typedef struct {
|
|||||||
double rate;
|
double rate;
|
||||||
|
|
||||||
// URIs
|
// URIs
|
||||||
LV2_URI_Map_Feature* map;
|
LV2_URID_Map* map;
|
||||||
struct {
|
struct {
|
||||||
uint32_t midi_event;
|
LV2_URID midi_event;
|
||||||
} uris;
|
} uris;
|
||||||
|
|
||||||
// Available kits
|
// Available kits
|
||||||
|
16
drmr.ttl
16
drmr.ttl
@ -1,10 +1,11 @@
|
|||||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#>.
|
@prefix lv2: <http://lv2plug.in/ns/lv2core#>.
|
||||||
@prefix ev: <http://lv2plug.in/ns/ext/event#> .
|
|
||||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
||||||
@prefix doap: <http://usefulinc.com/ns/doap#>.
|
@prefix doap: <http://usefulinc.com/ns/doap#>.
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
|
||||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
||||||
@prefix ui: <http://lv2plug.in/ns/extensions/ui#>.
|
@prefix ui: <http://lv2plug.in/ns/extensions/ui#>.
|
||||||
|
@prefix atom: <http://lv2plug.in/ns/ext/atom#> .
|
||||||
|
@prefix urid: <http://lv2plug.in/ns/ext/urid#> .
|
||||||
|
|
||||||
<http://github.com/nicklan/drmr>
|
<http://github.com/nicklan/drmr>
|
||||||
a lv2:InstrumentPlugin, lv2:Plugin;
|
a lv2:InstrumentPlugin, lv2:Plugin;
|
||||||
@ -15,14 +16,17 @@
|
|||||||
foaf:homepage <http://github.com/nick/drmr/wiki> ;
|
foaf:homepage <http://github.com/nick/drmr/wiki> ;
|
||||||
foaf:mbox <nick@afternight.org>
|
foaf:mbox <nick@afternight.org>
|
||||||
] ;
|
] ;
|
||||||
doap:license <http://usefulinc.com/doap/licenses/gpl>;
|
doap:license <http://usefulinc.com/doap/licenses/gpl> ;
|
||||||
|
lv2:requiredFeature urid:map ;
|
||||||
ui:ui <http://github.com/nicklan/drmr#ui> ;
|
ui:ui <http://github.com/nicklan/drmr#ui> ;
|
||||||
lv2:port [
|
lv2:port [
|
||||||
a ev:EventPort, lv2:InputPort;
|
a lv2:InputPort , atom:MessagePort;
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports <http://lv2plug.in/ns/ext/midi#MidiEvent> ,
|
||||||
|
<http://lv2plug.in/ns/ext/atom#Path> ;
|
||||||
lv2:index 0;
|
lv2:index 0;
|
||||||
ev:supportsEvent <http://lv2plug.in/ns/ext/midi#MidiEvent>;
|
lv2:symbol "control";
|
||||||
lv2:symbol "midi";
|
lv2:name "Control";
|
||||||
lv2:name "MIDI";
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
a lv2:AudioPort, lv2:OutputPort;
|
a lv2:AudioPort, lv2:OutputPort;
|
||||||
|
Loading…
Reference in New Issue
Block a user