aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/midi.c61
-rw-r--r--backends/midi.md3
2 files changed, 28 insertions, 36 deletions
diff --git a/backends/midi.c b/backends/midi.c
index f378f1e..1f0f2d5 100644
--- a/backends/midi.c
+++ b/backends/midi.c
@@ -13,9 +13,7 @@ enum /*_midi_channel_type*/ {
cc,
pressure,
aftertouch,
- pitchbend,
- nrpn,
- sysmsg
+ pitchbend
};
static struct {
@@ -145,10 +143,6 @@ static channel* midi_channel(instance* inst, char* spec, uint8_t flags){
ident.fields.type = note;
channel += 4;
}
- else if(!strncmp(channel, "nrpn", 4)){
- ident.fields.type = nrpn;
- channel += 4;
- }
else if(!strncmp(channel, "pressure", 8)){
ident.fields.type = pressure;
channel += 8;
@@ -205,9 +199,6 @@ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){
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;
}
snd_seq_event_output(sequencer, &ev);
@@ -217,6 +208,24 @@ static int midi_set(instance* inst, size_t num, channel** c, channel_value* v){
return 0;
}
+static char* midi_type_name(uint8_t type){
+ switch(type){
+ case none:
+ return "none";
+ case note:
+ return "note";
+ case cc:
+ return "cc";
+ case pressure:
+ return "pressure";
+ case aftertouch:
+ return "aftertouch";
+ case pitchbend:
+ return "pitch";
+ }
+ return "unknown";
+}
+
static int midi_handle(size_t num, managed_fd* fds){
snd_seq_event_t* ev = NULL;
instance* inst = NULL;
@@ -234,59 +243,45 @@ static int midi_handle(size_t num, managed_fd* fds){
while(snd_seq_event_input(sequencer, &ev) > 0){
event_type = NULL;
ident.label = 0;
+
+ ident.fields.channel = ev->data.note.channel;
+ ident.fields.control = ev->data.note.note;
+ val.normalised = (double) ev->data.note.velocity / 127.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;
if(ev->type == SND_SEQ_EVENT_NOTEOFF){
val.normalised = 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";
+ 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;
- event_type = "pitch";
+ 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;
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:
- case SND_SEQ_EVENT_REGPARAM:
- //FIXME value calculation
- ident.fields.type = nrpn;
- ident.fields.channel = ev->data.control.channel;
- ident.fields.control = ev->data.control.param;
+ val.normalised = (double) ev->data.control.value / 127.0;
break;
default:
LOG("Ignored event of unsupported type");
continue;
}
+ event_type = midi_type_name(ident.fields.type);
inst = mm_instance_find(BACKEND_NAME, ev->dest.port);
if(!inst){
//FIXME might want to return failure
diff --git a/backends/midi.md b/backends/midi.md
index 8188444..d3d6e33 100644
--- a/backends/midi.md
+++ b/backends/midi.md
@@ -30,7 +30,6 @@ The MIDI backend supports mapping different MIDI events to MIDIMonster channels.
* `pressure` - Note pressure/aftertouch messages
* `aftertouch` - Channel-wide aftertouch messages
* `pitch` - Channel pitchbend messages
-* `nrpn` - NRPNs (not yet implemented)
A MIDIMonster channel is specified using the syntax `channel<channel>.<type><index>`. The shorthand `ch` may be
used instead of the word `channel` (Note that `channel` here refers to the MIDI channel number).
@@ -57,7 +56,5 @@ Currently, no Note Off messages are sent (instead, Note On messages with a veloc
generated, which amount to the same thing according to the spec). This may be implemented as
a configuration option at a later time.
-NRPNs are not yet fully implemented, though rudimentary support is in the codebase.
-
To see which events your MIDI devices output, ALSA provides the `aseqdump` utility. You can
list all incoming events using `aseqdump -p <portname>`.