aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/midi.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2021-01-10 17:30:12 +0100
committercbdev <cb@cbcdn.com>2021-01-10 17:30:12 +0100
commita3a893f6b8b6c10ff281fcdfe0b4a4ddafe89023 (patch)
tree9492b5c9960ec746afb0fa6acfdaa178cac121ca /backends/midi.c
parent7902842bd10b17d8d5b6bfc586f440299646d48c (diff)
downloadmidimonster-a3a893f6b8b6c10ff281fcdfe0b4a4ddafe89023.tar.gz
midimonster-a3a893f6b8b6c10ff281fcdfe0b4a4ddafe89023.tar.bz2
midimonster-a3a893f6b8b6c10ff281fcdfe0b4a4ddafe89023.zip
Implement program change control for the midi, winmidi and jack backends (Fixes #79)
Diffstat (limited to 'backends/midi.c')
-rw-r--r--backends/midi.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/backends/midi.c b/backends/midi.c
index e32c975..10c8c4a 100644
--- a/backends/midi.c
+++ b/backends/midi.c
@@ -14,6 +14,7 @@ enum /*_midi_channel_type*/ {
pressure,
aftertouch,
pitchbend,
+ program,
rpn,
nrpn
};
@@ -167,6 +168,9 @@ static channel* midi_channel(instance* inst, char* spec, uint8_t flags){
else if(!strncmp(channel, "pitch", 5)){
ident.fields.type = pitchbend;
}
+ else if(!strncmp(channel, "program", 7)){
+ ident.fields.type = program;
+ }
else if(!strncmp(channel, "aftertouch", 10)){
ident.fields.type = aftertouch;
}
@@ -208,6 +212,9 @@ static void midi_tx(int port, uint8_t type, uint8_t channel, uint8_t control, ui
case aftertouch:
snd_seq_ev_set_chanpress(&ev, channel, value);
break;
+ case program:
+ snd_seq_ev_set_pgmchange(&ev, channel, value);
+ break;
}
snd_seq_event_output(sequencer, &ev);
@@ -269,6 +276,8 @@ static char* midi_type_name(uint8_t type){
return "aftertouch";
case pitchbend:
return "pitch";
+ case program:
+ return "program";
}
return "unknown";
}
@@ -399,6 +408,7 @@ static int midi_handle(size_t num, managed_fd* fds){
case SND_SEQ_EVENT_CHANPRESS:
ident.fields.type = aftertouch;
ident.fields.channel = ev->data.control.channel;
+ ident.fields.control = 0;
val.normalised = (double) ev->data.control.value / 127.0;
break;
case SND_SEQ_EVENT_PITCHBEND:
@@ -407,6 +417,12 @@ static int midi_handle(size_t num, managed_fd* fds){
ident.fields.channel = ev->data.control.channel;
val.normalised = ((double) ev->data.control.value + 8192) / 16383.0;
break;
+ case SND_SEQ_EVENT_PGMCHANGE:
+ ident.fields.type = program;
+ ident.fields.control = 0;
+ ident.fields.channel = ev->data.control.channel;
+ val.normalised = (double) ev->data.control.value / 127.0;
+ break;
case SND_SEQ_EVENT_CONTROLLER:
ident.fields.type = cc;
ident.fields.channel = ev->data.control.channel;
@@ -437,7 +453,7 @@ static int midi_handle(size_t num, managed_fd* fds){
}
if(midi_config.detect && event_type){
- if(ident.fields.type == pitchbend || ident.fields.type == aftertouch){
+ if(ident.fields.type == pitchbend || ident.fields.type == aftertouch || ident.fields.type == program){
LOGPF("Incoming data on channel %s.ch%d.%s", inst->name, ident.fields.channel, event_type);
}
else{