From a2b0728027dd8961ef84220c8c8eaf8a81154c71 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 30 Mar 2019 14:34:20 +0100 Subject: Fix MIDI mapping syntax --- backends/midi.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index d856ced..ad7f6fe 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -118,19 +118,30 @@ static channel* midi_channel(instance* instance, char* spec){ .label = 0 }; + //support deprecated syntax for a transition period... + uint8_t old_syntax = 0; char* channel; - if(!strncmp(spec, "cc", 2)){ + if(!strncmp(spec, "ch", 2)){ + channel = spec + 2; + if(!strncmp(spec, "channel", 7)){ + channel = spec + 7; + } + } + else if(!strncmp(spec, "cc", 2)){ ident.fields.type = cc; channel = spec + 2; + old_syntax = 1; } else if(!strncmp(spec, "note", 4)){ ident.fields.type = note; channel = spec + 4; + old_syntax = 1; } else if(!strncmp(spec, "nrpn", 4)){ ident.fields.type = nrpn; channel = spec + 4; + old_syntax = 1; } else{ fprintf(stderr, "Unknown MIDI channel specification %s\n", spec); @@ -138,19 +149,33 @@ static channel* midi_channel(instance* instance, char* spec){ } ident.fields.channel = strtoul(channel, &channel, 10); - - //FIXME test this - if(ident.fields.channel > 16){ + if(ident.fields.channel > 15){ fprintf(stderr, "MIDI channel out of range in channel spec %s\n", spec); return NULL; } if(*channel != '.'){ - fprintf(stderr, "Need MIDI channel specification of form channel.control, had %s\n", spec); + fprintf(stderr, "Need MIDI channel specification of form channel., had %s\n", spec); return NULL; } + //skip the period channel++; + if(!old_syntax){ + if(!strncmp(channel, "cc", 2)){ + ident.fields.type = cc; + channel += 2; + } + else if(!strncmp(channel, "note", 4)){ + ident.fields.type = note; + channel += 4; + } + else if(!strncmp(channel, "nrpn", 4)){ + ident.fields.type = nrpn; + channel += 4; + } + } + ident.fields.control = strtoul(channel, NULL, 10); if(ident.label){ -- cgit v1.2.3 From 6b97a08dee55ac4807902fc7ae1b4efe2911b873 Mon Sep 17 00:00:00 2001 From: cbdev Date: Mon, 1 Apr 2019 20:13:22 +0200 Subject: Implement pitch, aftertouch and pressure events for the MIDI backend --- backends/midi.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index ad7f6fe..2999e6b 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -24,6 +24,9 @@ enum /*_midi_channel_type*/ { none = 0, note, cc, + pressure, + aftertouch, + pitchbend, nrpn, sysmsg }; @@ -174,6 +177,16 @@ static channel* midi_channel(instance* instance, char* spec){ ident.fields.type = nrpn; channel += 4; } + else if(!strncmp(channel, "pressure", 8)){ + ident.fields.type = pressure; + channel += 8; + } + else if(!strncmp(channel, "pitch", 8)){ + ident.fields.type = pitchbend; + } + else if(!strncmp(channel, "aftertouch", 10)){ + ident.fields.type = aftertouch; + } } ident.fields.control = strtoul(channel, NULL, 10); @@ -209,6 +222,16 @@ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){ case cc: snd_seq_ev_set_controller(&ev, ident.fields.channel, ident.fields.control, v[u].normalised * 127.0); break; + case pressure: + snd_seq_ev_set_keypress(&ev, ident.fields.channel, ident.fields.control, v[u].normalised * 127.0); + + break; + case pitchbend: + snd_seq_ev_set_pitchbend(&ev, ident.fields.channel, (v[u].normalised * 16383.0) - 8192); + break; + case aftertouch: + snd_seq_ev_set_chanpress(&ev, ident.fields.channel, v[u].normalised * 127.0); + break; case nrpn: //FIXME set to nrpn output break; @@ -239,13 +262,28 @@ static int midi_handle(size_t num, managed_fd* fds){ switch(ev->type){ case SND_SEQ_EVENT_NOTEON: case SND_SEQ_EVENT_NOTEOFF: - case SND_SEQ_EVENT_KEYPRESS: case SND_SEQ_EVENT_NOTE: ident.fields.type = note; ident.fields.channel = ev->data.note.channel; ident.fields.control = ev->data.note.note; val.normalised = (double)ev->data.note.velocity / 127.0; break; + case SND_SEQ_EVENT_KEYPRESS: + ident.fields.type = pressure; + ident.fields.channel = ev->data.note.channel; + ident.fields.control = ev->data.note.note; + val.normalised = (double)ev->data.note.velocity / 127.0; + break; + case SND_SEQ_EVENT_CHANPRESS: + ident.fields.type = aftertouch; + ident.fields.channel = ev->data.control.channel; + val.normalised = (double)ev->data.control.value / 127.0; + break; + case SND_SEQ_EVENT_PITCHBEND: + ident.fields.type = pitchbend; + ident.fields.channel = ev->data.control.channel; + val.normalised = ((double)ev->data.control.value + 8192) / 16383.0; + break; case SND_SEQ_EVENT_CONTROLLER: ident.fields.type = cc; ident.fields.channel = ev->data.control.channel; -- cgit v1.2.3 From bbeade8898200a8024169ece30c620016fd5eaf1 Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 1 Aug 2019 20:58:21 +0200 Subject: Implement midi backend detect option --- backends/midi.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 2999e6b..c1480c0 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -31,6 +31,12 @@ enum /*_midi_channel_type*/ { sysmsg }; +static struct { + uint8_t detect; +} midi_config = { + .detect = 0 +}; + int init(){ backend midi = { .name = BACKEND_NAME, @@ -55,8 +61,8 @@ int init(){ return 1; } - snd_seq_nonblock(sequencer, 1); - + snd_seq_nonblock(sequencer, 1); + fprintf(stderr, "MIDI client ID is %d\n", snd_seq_client_id(sequencer)); return 0; } @@ -70,6 +76,14 @@ static int midi_configure(char* option, char* value){ return 0; } + if(!strcmp(option, "detect")){ + midi_config.detect = 1; + if(!strcmp(value, "off")){ + midi_config.detect = 0; + } + return 0; + } + fprintf(stderr, "Unknown MIDI backend option %s\n", option); return 1; } @@ -214,7 +228,7 @@ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){ snd_seq_ev_set_source(&ev, data->port); snd_seq_ev_set_subs(&ev); snd_seq_ev_set_direct(&ev); - + switch(ident.fields.type){ case note: snd_seq_ev_set_noteon(&ev, ident.fields.channel, ident.fields.control, v[u].normalised * 127.0); @@ -224,7 +238,6 @@ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){ break; case pressure: snd_seq_ev_set_keypress(&ev, ident.fields.channel, ident.fields.control, v[u].normalised * 127.0); - break; case pitchbend: snd_seq_ev_set_pitchbend(&ev, ident.fields.channel, (v[u].normalised * 16383.0) - 8192); @@ -249,6 +262,7 @@ static int midi_handle(size_t num, managed_fd* fds){ instance* inst = NULL; channel* changed = NULL; channel_value val; + char* event_type = NULL; midi_channel_ident ident = { .label = 0 }; @@ -258,6 +272,7 @@ static int midi_handle(size_t num, managed_fd* fds){ } while(snd_seq_event_input(sequencer, &ev) > 0){ + event_type = NULL; ident.label = 0; switch(ev->type){ case SND_SEQ_EVENT_NOTEON: @@ -267,22 +282,26 @@ static int midi_handle(size_t num, managed_fd* fds){ ident.fields.channel = ev->data.note.channel; ident.fields.control = ev->data.note.note; val.normalised = (double)ev->data.note.velocity / 127.0; + event_type = "note"; break; case SND_SEQ_EVENT_KEYPRESS: ident.fields.type = pressure; ident.fields.channel = ev->data.note.channel; ident.fields.control = ev->data.note.note; val.normalised = (double)ev->data.note.velocity / 127.0; + event_type = "pressure"; break; case SND_SEQ_EVENT_CHANPRESS: ident.fields.type = aftertouch; ident.fields.channel = ev->data.control.channel; val.normalised = (double)ev->data.control.value / 127.0; + event_type = "aftertouch"; break; case SND_SEQ_EVENT_PITCHBEND: ident.fields.type = pitchbend; ident.fields.channel = ev->data.control.channel; val.normalised = ((double)ev->data.control.value + 8192) / 16383.0; + event_type = "pitch"; break; case SND_SEQ_EVENT_CONTROLLER: ident.fields.type = cc; @@ -290,6 +309,7 @@ static int midi_handle(size_t num, managed_fd* fds){ ident.fields.control = ev->data.control.param; val.raw.u64 = ev->data.control.value; val.normalised = (double)ev->data.control.value / 127.0; + event_type = "cc"; break; case SND_SEQ_EVENT_CONTROL14: case SND_SEQ_EVENT_NONREGPARAM: @@ -318,6 +338,15 @@ static int midi_handle(size_t num, managed_fd* fds){ return 1; } } + + if(midi_config.detect && event_type){ + if(ident.fields.type == pitchbend || ident.fields.type == aftertouch){ + fprintf(stderr, "Incoming MIDI data on channel %s.ch%d.%s\n", inst->name, ident.fields.channel, event_type); + } + else{ + fprintf(stderr, "Incoming MIDI data on channel %s.ch%d.%s%d\n", inst->name, ident.fields.channel, event_type, ident.fields.control); + } + } } free(ev); return 0; @@ -375,13 +404,13 @@ static int midi_start(){ } //register all fds to core - nfds = snd_seq_poll_descriptors_count(sequencer, POLLIN | POLLOUT); + nfds = snd_seq_poll_descriptors_count(sequencer, POLLIN | POLLOUT); pfds = calloc(nfds, sizeof(struct pollfd)); if(!pfds){ fprintf(stderr, "Failed to allocate memory\n"); goto bail; } - nfds = snd_seq_poll_descriptors(sequencer, pfds, nfds, POLLIN | POLLOUT); + nfds = snd_seq_poll_descriptors(sequencer, pfds, nfds, POLLIN | POLLOUT); fprintf(stderr, "MIDI backend registering %d descriptors to core\n", nfds); for(p = 0; p < nfds; p++){ -- cgit v1.2.3 From 47a5f9a21bd661f9161d6175ebd074962daee255 Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 7 Aug 2019 17:25:24 +0200 Subject: Fix export visibilities for GCC --- backends/midi.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index c1480c0..9c6ba80 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -14,12 +14,6 @@ typedef union { uint64_t label; } midi_channel_ident; -/* - * TODO - * Optionally send note-off messages - * Optionally send updates as after-touch - */ - enum /*_midi_channel_type*/ { none = 0, note, -- cgit v1.2.3 From 48bf96602023b2ead855f13477b6f5e26b663b45 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 10 Aug 2019 20:30:07 +0200 Subject: Clean up & check unions --- backends/midi.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 9c6ba80..5b8e561 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -4,15 +4,6 @@ #define BACKEND_NAME "midi" static snd_seq_t* sequencer = NULL; -typedef union { - struct { - uint8_t pad[5]; - uint8_t type; - uint8_t channel; - uint8_t control; - } fields; - uint64_t label; -} midi_channel_ident; enum /*_midi_channel_type*/ { none = 0, @@ -44,6 +35,11 @@ int init(){ .shutdown = midi_shutdown }; + if(sizeof(midi_channel_ident) != sizeof(uint64_t)){ + fprintf(stderr, "MIDI channel identification union out of bounds\n"); + return 1; + } + if(snd_seq_open(&sequencer, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0){ fprintf(stderr, "Failed to open ALSA sequencer\n"); return 1; -- cgit v1.2.3 From 0906c00d23be220928a656476c26a490998e826e Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 24 Aug 2019 20:19:24 +0200 Subject: Only connect to ALSA when instances are requested --- backends/midi.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 5b8e561..88b841c 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -3,6 +3,7 @@ #include "midi.h" #define BACKEND_NAME "midi" +static char* sequencer_name = NULL; static snd_seq_t* sequencer = NULL; enum /*_midi_channel_type*/ { @@ -40,29 +41,19 @@ int init(){ return 1; } - if(snd_seq_open(&sequencer, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0){ - fprintf(stderr, "Failed to open ALSA sequencer\n"); - return 1; - } - //register backend if(mm_backend_register(midi)){ fprintf(stderr, "Failed to register MIDI backend\n"); return 1; } - snd_seq_nonblock(sequencer, 1); - - fprintf(stderr, "MIDI client ID is %d\n", snd_seq_client_id(sequencer)); return 0; } static int midi_configure(char* option, char* value){ if(!strcmp(option, "name")){ - if(snd_seq_set_client_name(sequencer, value) < 0){ - fprintf(stderr, "Failed to set MIDI client name to %s\n", value); - return 1; - } + free(sequencer_name); + sequencer_name = strdup(value); return 0; } @@ -361,6 +352,21 @@ static int midi_start(){ return 0; } + //connect to the sequencer + if(snd_seq_open(&sequencer, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0){ + fprintf(stderr, "Failed to open ALSA sequencer\n"); + return 0; + } + + snd_seq_nonblock(sequencer, 1); + fprintf(stderr, "MIDI client ID is %d\n", snd_seq_client_id(sequencer)); + + //update the sequencer client name + if(snd_seq_set_client_name(sequencer, sequencer_name) < 0){ + fprintf(stderr, "Failed to set MIDI client name to %s\n", sequencer_name); + return 1; + } + //create all ports for(p = 0; p < n; p++){ data = (midi_instance_data*) inst[p]->impl; @@ -437,12 +443,17 @@ static int midi_shutdown(){ free(inst); //close midi - snd_seq_close(sequencer); - sequencer = NULL; + if(sequencer){ + snd_seq_close(sequencer); + sequencer = NULL; + } //free configuration cache snd_config_update_free_global(); + free(sequencer_name); + sequencer_name = NULL; + fprintf(stderr, "MIDI backend shut down\n"); return 0; } -- cgit v1.2.3 From ba8cb9bfaf0c3699a728cef6918d7433a8690936 Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 24 Aug 2019 22:13:49 +0200 Subject: Fix NULL pointer access --- backends/midi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 88b841c..571a61d 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -362,7 +362,7 @@ static int midi_start(){ fprintf(stderr, "MIDI client ID is %d\n", snd_seq_client_id(sequencer)); //update the sequencer client name - if(snd_seq_set_client_name(sequencer, sequencer_name) < 0){ + if(snd_seq_set_client_name(sequencer, sequencer_name ? sequencer_name : "MIDIMonster") < 0){ fprintf(stderr, "Failed to set MIDI client name to %s\n", sequencer_name); return 1; } -- cgit v1.2.3 From 1c8d7c570678c2f4f3bf61529489336f9d085f8d Mon Sep 17 00:00:00 2001 From: cbdev Date: Sun, 15 Sep 2019 23:09:44 +0200 Subject: Fix minor MIDI issues --- backends/midi.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 571a61d..65ce48a 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -84,14 +84,14 @@ static instance* midi_instance(){ return inst; } -static int midi_configure_instance(instance* instance, char* option, char* value){ - midi_instance_data* data = (midi_instance_data*) instance->impl; +static int midi_configure_instance(instance* inst, char* option, char* value){ + midi_instance_data* data = (midi_instance_data*) inst->impl; //FIXME maybe allow connecting more than one device if(!strcmp(option, "read")){ //connect input device if(data->read){ - fprintf(stderr, "MIDI port already connected to an input device\n"); + fprintf(stderr, "MIDI instance %s was already connected to an input device\n", inst->name); return 1; } data->read = strdup(value); @@ -100,7 +100,7 @@ static int midi_configure_instance(instance* instance, char* option, char* value else if(!strcmp(option, "write")){ //connect output device if(data->write){ - fprintf(stderr, "MIDI port already connected to an output device\n"); + fprintf(stderr, "MIDI instance %s was already connected to an output device\n", inst->name); return 1; } data->write = strdup(value); @@ -111,7 +111,7 @@ static int midi_configure_instance(instance* instance, char* option, char* value return 1; } -static channel* midi_channel(instance* instance, char* spec){ +static channel* midi_channel(instance* inst, char* spec){ midi_channel_ident ident = { .label = 0 }; @@ -142,13 +142,13 @@ static channel* midi_channel(instance* instance, char* spec){ old_syntax = 1; } else{ - fprintf(stderr, "Unknown MIDI channel specification %s\n", spec); + fprintf(stderr, "Unknown MIDI channel control type in %s\n", spec); return NULL; } ident.fields.channel = strtoul(channel, &channel, 10); if(ident.fields.channel > 15){ - fprintf(stderr, "MIDI channel out of range in channel spec %s\n", spec); + fprintf(stderr, "MIDI channel out of range in midi channel spec %s\n", spec); return NULL; } @@ -176,18 +176,22 @@ static channel* midi_channel(instance* instance, char* spec){ ident.fields.type = pressure; channel += 8; } - else if(!strncmp(channel, "pitch", 8)){ + else if(!strncmp(channel, "pitch", 5)){ ident.fields.type = pitchbend; } else if(!strncmp(channel, "aftertouch", 10)){ ident.fields.type = aftertouch; } + else{ + fprintf(stderr, "Unknown MIDI channel control type in %s\n", spec); + return NULL; + } } ident.fields.control = strtoul(channel, NULL, 10); if(ident.label){ - return mm_channel(instance, ident.label, 1); + return mm_channel(inst, ident.label, 1); } return NULL; @@ -196,13 +200,12 @@ static channel* midi_channel(instance* instance, char* spec){ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){ size_t u; snd_seq_event_t ev; - midi_instance_data* data; + midi_instance_data* data = (midi_instance_data*) inst->impl; midi_channel_ident ident = { .label = 0 }; for(u = 0; u < num; u++){ - data = (midi_instance_data*) c[u]->instance->impl; ident.label = c[u]->ident; snd_seq_ev_clear(&ev); @@ -334,7 +337,7 @@ static int midi_handle(size_t num, managed_fd* fds){ } static int midi_start(){ - size_t n, p; + size_t n = 0, p; int nfds, rv = 1; struct pollfd* pfds = NULL; instance** inst = NULL; -- cgit v1.2.3 From fe4a7b538b9b6c53299d883bee258e4d3597be9d Mon Sep 17 00:00:00 2001 From: cbdev Date: Fri, 20 Sep 2019 03:43:13 +0200 Subject: Update documentation, fix minor leaks --- backends/midi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 65ce48a..d9ac698 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -358,7 +358,7 @@ static int midi_start(){ //connect to the sequencer if(snd_seq_open(&sequencer, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0){ fprintf(stderr, "Failed to open ALSA sequencer\n"); - return 0; + goto bail; } snd_seq_nonblock(sequencer, 1); @@ -367,7 +367,7 @@ static int midi_start(){ //update the sequencer client name if(snd_seq_set_client_name(sequencer, sequencer_name ? sequencer_name : "MIDIMonster") < 0){ fprintf(stderr, "Failed to set MIDI client name to %s\n", sequencer_name); - return 1; + goto bail; } //create all ports -- cgit v1.2.3 From 65bd41387c8dbf67812de1881198a47c9bb4b55e Mon Sep 17 00:00:00 2001 From: cbdev Date: Sat, 5 Oct 2019 19:30:22 +0200 Subject: Implement detect option for winmidi --- backends/midi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index d9ac698..536457d 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -56,8 +56,7 @@ static int midi_configure(char* option, char* value){ sequencer_name = strdup(value); return 0; } - - if(!strcmp(option, "detect")){ + else if(!strcmp(option, "detect")){ midi_config.detect = 1; if(!strcmp(value, "off")){ midi_config.detect = 0; -- cgit v1.2.3 From d29a499113d389a8bee9bf21bf5969d41c9cf307 Mon Sep 17 00:00:00 2001 From: Leon Scheid Date: Thu, 21 Nov 2019 18:41:02 +0100 Subject: Chane NoteOff behavior --- backends/midi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index 536457d..d609ad9 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -259,14 +259,20 @@ static int midi_handle(size_t num, managed_fd* fds){ ident.label = 0; switch(ev->type){ case SND_SEQ_EVENT_NOTEON: - case SND_SEQ_EVENT_NOTEOFF: - case SND_SEQ_EVENT_NOTE: ident.fields.type = note; ident.fields.channel = ev->data.note.channel; ident.fields.control = ev->data.note.note; val.normalised = (double)ev->data.note.velocity / 127.0; event_type = "note"; break; + case SND_SEQ_EVENT_NOTEOFF: + ident.fields.type = note; + ident.fields.channel = ev->data.note.channel; + ident.fields.control = ev->data.note.note; + val.normalised = (double)0; + event_type = "note"; + break; + case SND_SEQ_EVENT_NOTE: case SND_SEQ_EVENT_KEYPRESS: ident.fields.type = pressure; ident.fields.channel = ev->data.note.channel; -- cgit v1.2.3 From 1aa8b88a1df5539fa7ad4004cfcbf3b8438486b4 Mon Sep 17 00:00:00 2001 From: Leon Scheid Date: Fri, 22 Nov 2019 15:40:11 +0100 Subject: Remove unnecessary case --- backends/midi.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index d609ad9..cde278b 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -259,20 +259,17 @@ static int midi_handle(size_t num, managed_fd* fds){ ident.label = 0; switch(ev->type){ case SND_SEQ_EVENT_NOTEON: - ident.fields.type = note; - ident.fields.channel = ev->data.note.channel; - ident.fields.control = ev->data.note.note; - val.normalised = (double)ev->data.note.velocity / 127.0; - event_type = "note"; - break; case SND_SEQ_EVENT_NOTEOFF: + case SND_SEQ_EVENT_NOTE: ident.fields.type = note; ident.fields.channel = ev->data.note.channel; ident.fields.control = ev->data.note.note; - val.normalised = (double)0; + val.normalised = (double)ev->data.note.velocity / 127.0; + if(ev->type == SND_SEQ_EVENT_NOTEOFF){ + val.normalised = 0; + } event_type = "note"; break; - case SND_SEQ_EVENT_NOTE: case SND_SEQ_EVENT_KEYPRESS: ident.fields.type = pressure; ident.fields.channel = ev->data.note.channel; -- cgit v1.2.3 From 1107a91861189d28d771d02d721d61b403aac38a Mon Sep 17 00:00:00 2001 From: cbdev Date: Wed, 4 Dec 2019 01:21:14 +0100 Subject: Explicitly mark the backend init symbol visible --- backends/midi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index cde278b..f380f59 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -23,7 +23,7 @@ static struct { .detect = 0 }; -int init(){ +MM_PLUGIN_API int init(){ backend midi = { .name = BACKEND_NAME, .conf = midi_configure, -- cgit v1.2.3 From 3eada28582b144519e95a44ee3adc3f46d39036e Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 5 Dec 2019 21:05:14 +0100 Subject: Add flags parameter to channel parser plugin API (Fixes #31) --- backends/midi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/midi.c') diff --git a/backends/midi.c b/backends/midi.c index f380f59..92776ca 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -110,7 +110,7 @@ static int midi_configure_instance(instance* inst, char* option, char* value){ return 1; } -static channel* midi_channel(instance* inst, char* spec){ +static channel* midi_channel(instance* inst, char* spec, uint8_t flags){ midi_channel_ident ident = { .label = 0 }; -- cgit v1.2.3