upgrade to libremidi 5.1, raylib and raygui latest

This commit is contained in:
Sebastian @ HfG
2025-06-13 19:16:35 +02:00
parent 62454960d1
commit 2cc6839009
112 changed files with 6484 additions and 1946 deletions
@@ -71,20 +71,22 @@ inline uint64_t AudioConvertHostTimeToNanos(uint64_t hostTime)
return static_cast<uint64_t>(res);
}
#endif
static inline auto get_cfstring_property(MIDIObjectRef prop, CFStringRef name)
{
CFStringRef str = nullptr;
MIDIObjectGetStringProperty(prop, name, &str);
return CFString_handle{str};
};
// This function was submitted by Douglas Casey Tucker and apparently
// derived largely from PortMidi.
inline CFStringRef EndpointName(MIDIEndpointRef endpoint, bool isExternal)
{
CFMutableStringRef result = CFStringCreateMutable(nullptr, 0);
static constexpr auto getProp = [](MIDIObjectRef prop) {
CFStringRef str = nullptr;
MIDIObjectGetStringProperty(prop, kMIDIPropertyName, &str);
return CFString_handle{str};
};
// Begin with the endpoint's name.
if (auto endpoint_name = getProp(endpoint))
if (auto endpoint_name = get_cfstring_property(endpoint, kMIDIPropertyName))
{
CFStringAppend(result, endpoint_name.get());
}
@@ -101,7 +103,7 @@ inline CFStringRef EndpointName(MIDIEndpointRef endpoint, bool isExternal)
if (CFStringGetLength(result) == 0)
{
// endpoint name has zero length -- try the entity
if (auto entity_name = getProp(entity))
if (auto entity_name = get_cfstring_property(entity, kMIDIPropertyName))
{
CFStringAppend(result, entity_name.get());
}
@@ -112,7 +114,7 @@ inline CFStringRef EndpointName(MIDIEndpointRef endpoint, bool isExternal)
if (device == 0)
goto finish;
if (auto dev_name = getProp(device))
if (auto dev_name = get_cfstring_property(device, kMIDIPropertyName))
{
const auto dev_strlen = CFStringGetLength(dev_name.get());
@@ -78,13 +78,55 @@ public:
if (!ok)
return {};
// Get the MIDI device from the entity
libremidi::port_information::port_type type{};
libremidi::container_identifier usb_location_id{};
libremidi::device_identifier usb_vendor_product{};
{
MIDIDeviceRef device{};
if (MIDIEntityGetDevice(e, &device) == noErr)
{
if (device)
{
using enum libremidi::port_information::port_type;
SInt32 devid_res{};
if (MIDIObjectGetIntegerProperty(device, CFSTR("USBLocationID"), &devid_res) == noErr)
{
type = (libremidi::port_information::port_type)(hardware | usb);
usb_location_id = (uint64_t)devid_res;
}
SInt32 vendor_res{};
if (MIDIObjectGetIntegerProperty(device, CFSTR("USBVendorProduct"), &vendor_res)
== noErr)
{
type = (libremidi::port_information::port_type)(hardware | usb);
usb_vendor_product = (uint64_t)vendor_res;
}
const auto driver = get_string_property(device, kMIDIPropertyDriverOwner);
if (driver == "com.apple.AppleMIDIUSBDriver")
type = (libremidi::port_information::port_type)(hardware | usb);
if (driver == "com.apple.AppleMIDIBluetoothDriver")
type = (libremidi::port_information::port_type)(hardware | bluetooth);
if (driver == "com.apple.AppleMIDIIACDriver")
type = (libremidi::port_information::port_type)(software);
if (driver == "com.apple.AppleMIDIRTPDriver")
type = (libremidi::port_information::port_type)(network);
}
}
}
return std::conditional_t<Input, input_port, output_port>{
{.client = (std::uintptr_t)this->client,
.container = usb_location_id,
.device = usb_vendor_product,
.port = std::bit_cast<uint32_t>(get_int_property(obj, kMIDIPropertyUniqueID)),
.manufacturer = get_string_property(obj, kMIDIPropertyManufacturer),
.device_name = get_string_property(obj, kMIDIPropertyModel),
.port_name = get_string_property(obj, kMIDIPropertyName),
.display_name = get_string_property(obj, kMIDIPropertyDisplayName)}};
.display_name = get_string_property(obj, kMIDIPropertyDisplayName),
.type = type}};
}
std::vector<libremidi::input_port> get_input_ports() const noexcept override