From 445b696f43a9106f8871a67c077e990ce1ca14ab Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 11 Jan 2025 14:59:22 +0100 Subject: Age out bpm data --- MIDI.cpp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'MIDI.cpp') diff --git a/MIDI.cpp b/MIDI.cpp index 1e43a96..afcca28 100644 --- a/MIDI.cpp +++ b/MIDI.cpp @@ -21,25 +21,29 @@ MIDI::MIDI() debug_cout << "in_port: " << std::to_string(in_port) << std::endl; -#if 1 - snd_seq_addr_t sender, dest; - snd_seq_port_subscribe_t *subs; - sender.client = 24; - sender.port = 0; - dest.client = snd_seq_client_id(seq_handle); - dest.port = in_port; - snd_seq_port_subscribe_alloca(&subs); - snd_seq_port_subscribe_set_sender(subs, &sender); - snd_seq_port_subscribe_set_dest(subs, &dest); - snd_seq_port_subscribe_set_queue(subs, 1); - snd_seq_port_subscribe_set_time_update(subs, 1); - snd_seq_port_subscribe_set_time_real(subs, 1); - // TODO: fix timestamp (currently always 0) - if (0 > snd_seq_subscribe_port(seq_handle, subs)) -#endif - //if (0 > snd_seq_connect_from(seq_handle, in_port, 24, 0)) - { - throw std::runtime_error("MIDI port couldn't be connected"); + if (1) { + snd_seq_addr_t sender, dest; + snd_seq_port_subscribe_t *subs; + sender.client = 24; + sender.port = 0; + dest.client = snd_seq_client_id(seq_handle); + dest.port = in_port; + snd_seq_port_subscribe_alloca(&subs); + snd_seq_port_subscribe_set_sender(subs, &sender); + snd_seq_port_subscribe_set_dest(subs, &dest); + snd_seq_port_subscribe_set_queue(subs, 1); + snd_seq_port_subscribe_set_time_update(subs, 1); + snd_seq_port_subscribe_set_time_real(subs, 1); + // TODO: fix timestamp (currently always 0) + if (0 > snd_seq_subscribe_port(seq_handle, subs)) + { + throw std::runtime_error("MIDI port couldn't be connected"); + } + } else { + if (0 > snd_seq_connect_from(seq_handle, in_port, 24, 0)) + { + throw std::runtime_error("MIDI port couldn't be connected"); + } } npfd = snd_seq_poll_descriptors_count(seq_handle, POLLIN); @@ -150,6 +154,7 @@ void MIDI::process(snd_seq_event_t *ev) } signal_count_events(snd_seq_event_length(ev)); + //log_cout << fmt::format("MIDI Bytes: {}", snd_seq_event_length(ev)) << std::endl; } void MIDI::flush() -- cgit v1.2.3