13
0

Sort MIDI Ports by human readable name in connection matrix

This is mainly for the benefit of CoreMIDI where MIDI
ports are identified by kMIDIPropertyUniqueID and ALSA
where Ardour uses a unique hash for persistent names.
This commit is contained in:
Robin Gareus 2024-07-31 17:38:40 +02:00
parent cb34845498
commit 170bc45de9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -628,10 +628,19 @@ PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inp
if (ports.size () > 0) {
struct SortByPortName {
bool _use_pretty_name;
SortByPortName (bool use_pretty_name) : _use_pretty_name (use_pretty_name) {}
bool operator() (std::string const& lhs, std::string const& rhs) const {
if (_use_pretty_name) {
/* add port-name as suffix (in case pretty-name is unset) */
std::string l = AudioEngine::instance()->get_hardware_port_name_by_name (lhs) + lhs;
std::string r = AudioEngine::instance()->get_hardware_port_name_by_name (rhs) + rhs;
return PBD::naturally_less (l.c_str (), r.c_str ());
} else {
return PBD::naturally_less (lhs.c_str (), rhs.c_str ());
}
} port_sorter;
}
} port_sorter (type == DataType::MIDI);
std::sort (ports.begin (), ports.end (), port_sorter);