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 )
|
||||
|
||||
set_target_properties (drmr
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS "-std=gnu99"
|
||||
)
|
||||
|
||||
set (ui_compile_flags "-std=gnu99")
|
||||
|
||||
if (NOT USE_NKNOB)
|
||||
set (ui_compile_flags "-DNO_NKNOB")
|
||||
set (ui_compile_flags "${ui_compile_flags} -DNO_NKNOB")
|
||||
endif (NOT USE_NKNOB)
|
||||
|
||||
if (SAMP_ZERO_POS GREATER "-1" AND SAMP_ZERO_POS LESS "4")
|
||||
|
28
drmr.c
28
drmr.c
@ -81,17 +81,16 @@ instantiate(const LV2_Descriptor* descriptor,
|
||||
|
||||
// Map midi uri
|
||||
while(*features) {
|
||||
if (!strcmp((*features)->URI, LV2_URI_MAP_URI)) {
|
||||
drmr->map = (LV2_URI_Map_Feature *)((*features)->data);
|
||||
drmr->uris.midi_event = drmr->map->uri_to_id
|
||||
(drmr->map->callback_data,
|
||||
"http://lv2plug.in/ns/ext/event",
|
||||
if (!strcmp((*features)->URI, LV2_URID_URI "#map")) {
|
||||
drmr->map = (LV2_URID_Map *)((*features)->data);
|
||||
drmr->uris.midi_event =
|
||||
drmr->map->map(drmr->map->handle,
|
||||
"http://lv2plug.in/ns/ext/midi#MidiEvent");
|
||||
}
|
||||
features++;
|
||||
}
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
@ -126,8 +125,8 @@ connect_port(LV2_Handle instance,
|
||||
DrMr* drmr = (DrMr*)instance;
|
||||
DrMrPortIndex port_index = (DrMrPortIndex)port;
|
||||
switch (port_index) {
|
||||
case DRMR_MIDI:
|
||||
drmr->midi_port = (LV2_Event_Buffer*)data;
|
||||
case DRMR_CONTROL:
|
||||
drmr->control_port = (LV2_Atom_Sequence*)data;
|
||||
break;
|
||||
case DRMR_LEFT:
|
||||
drmr->left = (float*)data;
|
||||
@ -191,13 +190,10 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
||||
if (kitInt != drmr->curKit) // requested a new kit
|
||||
pthread_cond_signal(&drmr->load_cond);
|
||||
|
||||
LV2_Event_Iterator eit;
|
||||
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)) {
|
||||
cur_ev = lv2_event_get(&eit,&data);
|
||||
if (cur_ev->type == drmr->uris.midi_event) {
|
||||
LV2_SEQUENCE_FOREACH(drmr->control_port, i) {
|
||||
LV2_Atom_Event* const ev = lv2_sequence_iter_get(i);
|
||||
if (ev->body.type == drmr->uris.midi_event) {
|
||||
uint8_t* const data = (uint8_t* const)(ev + 1);
|
||||
//int channel = *data & 15;
|
||||
switch ((*data) >> 4) {
|
||||
case 8: // ignore note-offs for now, should probably be a setting
|
||||
@ -225,8 +221,6 @@ static void run(LV2_Handle instance, uint32_t n_samples) {
|
||||
printf("Unhandeled status: %i\n",(*data)>>4);
|
||||
}
|
||||
} else printf("unrecognized event\n");
|
||||
lv2_event_increment(&eit);
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0;i<n_samples;i++) {
|
||||
|
15
drmr.h
15
drmr.h
@ -20,10 +20,11 @@
|
||||
#include <sndfile.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/ext/event/event.h"
|
||||
#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h"
|
||||
#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h"
|
||||
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
|
||||
|
||||
// drumkit scanned from a hydrogen xml file
|
||||
typedef struct {
|
||||
@ -67,7 +68,7 @@ typedef struct {
|
||||
#define GAIN_MAX 6.0f
|
||||
|
||||
typedef enum {
|
||||
DRMR_MIDI = 0,
|
||||
DRMR_CONTROL = 0,
|
||||
DRMR_LEFT,
|
||||
DRMR_RIGHT,
|
||||
DRMR_KITNUM,
|
||||
@ -143,7 +144,7 @@ typedef struct {
|
||||
// Ports
|
||||
float* left;
|
||||
float* right;
|
||||
LV2_Event_Buffer *midi_port;
|
||||
LV2_Atom_Sequence *control_port;
|
||||
|
||||
// params
|
||||
float** gains;
|
||||
@ -153,9 +154,9 @@ typedef struct {
|
||||
double rate;
|
||||
|
||||
// URIs
|
||||
LV2_URI_Map_Feature* map;
|
||||
LV2_URID_Map* map;
|
||||
struct {
|
||||
uint32_t midi_event;
|
||||
LV2_URID midi_event;
|
||||
} uris;
|
||||
|
||||
// Available kits
|
||||
|
16
drmr.ttl
16
drmr.ttl
@ -1,10 +1,11 @@
|
||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#>.
|
||||
@prefix ev: <http://lv2plug.in/ns/ext/event#> .
|
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
||||
@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 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>
|
||||
a lv2:InstrumentPlugin, lv2:Plugin;
|
||||
@ -15,14 +16,17 @@
|
||||
foaf:homepage <http://github.com/nick/drmr/wiki> ;
|
||||
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> ;
|
||||
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;
|
||||
ev:supportsEvent <http://lv2plug.in/ns/ext/midi#MidiEvent>;
|
||||
lv2:symbol "midi";
|
||||
lv2:name "MIDI";
|
||||
lv2:symbol "control";
|
||||
lv2:name "Control";
|
||||
],
|
||||
[
|
||||
a lv2:AudioPort, lv2:OutputPort;
|
||||
|
Loading…
Reference in New Issue
Block a user