| 16 | #include <iostream> |
| 17 | |
| 18 | struct midi_ci_processor |
| 19 | { |
| 20 | midi::sysex7_collector sysex7; |
| 21 | midi::sysex8_collector sysex8; |
| 22 | |
| 23 | libremidi::observer obs; |
| 24 | libremidi::midi_out midiout; |
| 25 | libremidi::midi_in midiin; |
| 26 | |
| 27 | midi_ci_processor() |
| 28 | : sysex7{[this](const midi::sysex7& m) { on_sysex7(m); }} |
| 29 | , sysex8{[this](const midi::sysex8& m, uint8_t stream_id) { on_sysex8(m, stream_id); }} |
| 30 | , obs{{.track_any = true}, libremidi::midi2::observer_default_configuration()} |
| 31 | , midiout{{}, libremidi::midi_out_configuration_for(obs)} |
| 32 | , midiin{ |
| 33 | {// Set our callback function. |
| 34 | .on_message = [&](const libremidi::ump& message) { on_ump(message); }}, |
| 35 | libremidi::midi_in_configuration_for(obs)} |
| 36 | { |
| 37 | sysex7.set_max_sysex_data_size(65535); |
| 38 | sysex8.set_max_sysex_data_size(65535); |
| 39 | } |
| 40 | |
| 41 | // 1. Create the connection |
| 42 | void open() |
| 43 | { |
| 44 | // Opening midi input and output |
| 45 | { |
| 46 | auto pi = obs.get_input_ports(); |
| 47 | if (pi.empty()) |
| 48 | { |
| 49 | throw "No MIDI 2 input device found\n"; |
| 50 | } |
| 51 | |
| 52 | for (const auto& port : pi) |
| 53 | { |
| 54 | std::cout << "In: " << port.port_name << " | " << port.display_name << std::endl; |
| 55 | } |
| 56 | |
| 57 | midiin.open_port(pi[1]); |
| 58 | } |
| 59 | |
| 60 | { |
| 61 | auto po = obs.get_output_ports(); |
| 62 | if (po.empty()) |
| 63 | { |
| 64 | throw "No MIDI 2 output device found\n"; |
| 65 | } |
| 66 | |
| 67 | for (const auto& port : po) |
| 68 | { |
| 69 | std::cout << "Out: " << port.port_name << " | " << port.display_name << std::endl; |
| 70 | } |
| 71 | midiout.open_port(po[1]); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // 2. Top-level UMP processing |
nothing calls this directly
no outgoing calls
no test coverage detected