From b7276fa1aa12cc3384ee647e842c9f3d37ff3e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sat, 31 Aug 2024 18:12:03 -0400 Subject: [PATCH] [midi] Various improvements in particular to naming of ports --- 3rdparty/libremidi | 2 +- src/ossia/protocols/midi/midi_device.cpp | 3 ++- src/ossia/protocols/midi/midi_device.hpp | 2 +- src/ossia/protocols/midi/midi_protocol.cpp | 9 ++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/3rdparty/libremidi b/3rdparty/libremidi index ec279521413..82a6ee1951e 160000 --- a/3rdparty/libremidi +++ b/3rdparty/libremidi @@ -1 +1 @@ -Subproject commit ec2795214134161e7eebad4518ee0af163bbb92e +Subproject commit 82a6ee1951e6c6b718c2bc9233718258a1278bb2 diff --git a/src/ossia/protocols/midi/midi_device.cpp b/src/ossia/protocols/midi/midi_device.cpp index 1d17cf67b78..4d5666a945a 100644 --- a/src/ossia/protocols/midi/midi_device.cpp +++ b/src/ossia/protocols/midi/midi_device.cpp @@ -8,10 +8,11 @@ namespace ossia::net::midi { -midi_device::midi_device(std::unique_ptr prot) +midi_device::midi_device(std::string name, std::unique_ptr prot) : ossia::net::device_base{std::move(prot)} , midi_node{*this} { + m_name = name; m_capabilities.change_tree = true; m_protocol->set_device(*this); m_parameter = std::make_unique( diff --git a/src/ossia/protocols/midi/midi_device.hpp b/src/ossia/protocols/midi/midi_device.hpp index 70094ecfc56..0e73f203cc7 100644 --- a/src/ossia/protocols/midi/midi_device.hpp +++ b/src/ossia/protocols/midi/midi_device.hpp @@ -10,7 +10,7 @@ class OSSIA_EXPORT midi_device final , public midi_node { public: - midi_device(std::unique_ptr prot); + midi_device(std::string name, std::unique_ptr prot); ~midi_device(); //! Create a default MIDI tree with all the nodes available diff --git a/src/ossia/protocols/midi/midi_protocol.cpp b/src/ossia/protocols/midi/midi_protocol.cpp index 1990c6177d4..8ea3ef7efe1 100644 --- a/src/ossia/protocols/midi/midi_protocol.cpp +++ b/src/ossia/protocols/midi/midi_protocol.cpp @@ -65,16 +65,15 @@ std::string midi_protocol::get_midi_port_name(ossia::net::device_base* dev, const midi_info& info) { std::string name{}; + const bool input = info.type == midi_info::Type::Input; if(dev) - name = dev->get_name(); + name = (input ? "i " : "o ") + dev->get_name(); else { if(info.is_virtual) - name = info.type == midi_info::Type::Input ? "libossia MIDI virtual input" - : "libossia MIDI virtual output"; + name = input ? "i libossia virtual" : "o libossia virtual"; else - name = info.type == midi_info::Type::Input ? "libossia MIDI input" - : "libossia MIDI output"; + name = input ? "i libossia" : "o libossia"; } return name; }