MCPcopy Create free account
hub / github.com/celtera/libremidi / lookup_api

Function lookup_api

examples/lookup.cpp:21–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include <thread>
20
21void lookup_api(libremidi::API api, const libremidi::input_port& searched)
22{
23 std::string_view api_name = libremidi::get_api_display_name(api);
24 std::cout << "Displaying ports for: " << api_name << std::endl;
25
26 // On Windows 10, apparently the MIDI devices aren't exactly available as soon as the app open...
27 std::this_thread::sleep_for(std::chrono::milliseconds(100));
28
29 libremidi::observer midi{
30 {.track_hardware = true, .track_virtual = true}, libremidi::observer_configuration_for(api)};
31
32 std::this_thread::sleep_for(std::chrono::milliseconds(100));
33
34 {
35 // Check inputs.
36 auto ports = midi.get_input_ports();
37 auto res
38 = libremidi::find_closest_port(searched, std::span<const libremidi::input_port>(ports));
39 if (res.found) {
40 std::cout << "Found: " << *res.port << "\n";
41 }
42 }
43}
44
45int main()
46{

Callers 1

mainFunction · 0.85

Calls 2

find_closest_portFunction · 0.85
get_input_portsMethod · 0.45

Tested by

no test coverage detected