From b2d49c7c8fd55e5ca87a1c538a05a6ec18d4cfcb Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Wed, 8 Dec 2010 13:24:21 +0100 Subject: [PATCH] midiview: support specifying MIDI channel list --- examples/midiview.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/midiview.c b/examples/midiview.c index c211bd0..e8c6194 100644 --- a/examples/midiview.c +++ b/examples/midiview.c @@ -49,6 +49,8 @@ float avgnotes = 0.0; int cur_blip = 0; struct blip blips[NUM_BLIPS]; +uint16_t channels = 0; + snd_seq_t *open_seq(void) { snd_seq_t *seq_handle; @@ -94,6 +96,8 @@ int midi_action(snd_seq_t *seq_handle) { snd_seq_event_input(seq_handle, &ev); switch (ev->type) { case SND_SEQ_EVENT_NOTEON: + if (channels && !(channels & (1<data.note.channel))) + break; if (ev->data.note.velocity != 0) { note_on(ev->data.note.note, ev->data.note.velocity); cnt++; @@ -208,7 +212,7 @@ int main (int argc, char *argv[]) pfd = malloc(npfd * sizeof(*pfd)); snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN); - if (argc == 2) { + if (argc >= 2) { snd_seq_addr_t addr; if (snd_seq_parse_address(seq_handle, &addr, argv[1]) == 0) { if (snd_seq_connect_from(seq_handle, portid, addr.client, addr.port) == 0) { @@ -217,6 +221,10 @@ int main (int argc, char *argv[]) } } + int i; + for (i=2; i 0) notes = midi_action(seq_handle); - int pnotes = notes; - if (pnotes > 1) - pnotes = 1; + int pnotes = (notes+2)/3; nps = pnotes / ftime * 1.2; -- 2.52.0