From ed44b513eec65a3cc32db82e9caaccbf1a0155b4 Mon Sep 17 00:00:00 2001 From: TJ Lambert Date: Fri, 9 Sep 2022 09:44:59 -0500 Subject: [PATCH 1/2] [CoreMIDI] Updates for Xcode14 Beta 1 --- src/CoreMidi/MidiBluetoothDriver.cs | 49 +++++++++++++++++++ src/coremidi.cs | 38 ++++++++++++++ src/frameworks.sources | 3 ++ .../common-CoreMIDI.ignore | 2 + .../api-annotations-dotnet/iOS-CoreMIDI.todo | 10 ---- .../macOS-CoreMIDI.todo | 10 ---- .../tvOS-CoreMIDI.ignore} | 2 +- tests/xtro-sharpie/common-CoreMIDI.ignore | 2 + tests/xtro-sharpie/iOS-CoreMIDI.todo | 10 ---- tests/xtro-sharpie/macOS-CoreMIDI.todo | 10 ---- ...hOS-CoreMIDI.todo => tvOS-CoreMIDI.ignore} | 2 +- ...-CoreMIDI.todo => watchOS-CoreMIDI.ignore} | 2 +- 12 files changed, 97 insertions(+), 43 deletions(-) create mode 100644 src/CoreMidi/MidiBluetoothDriver.cs delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreMIDI.todo delete mode 100644 tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreMIDI.todo rename tests/xtro-sharpie/{tvOS-CoreMIDI.todo => api-annotations-dotnet/tvOS-CoreMIDI.ignore} (93%) delete mode 100644 tests/xtro-sharpie/iOS-CoreMIDI.todo delete mode 100644 tests/xtro-sharpie/macOS-CoreMIDI.todo rename tests/xtro-sharpie/{watchOS-CoreMIDI.todo => tvOS-CoreMIDI.ignore} (93%) rename tests/xtro-sharpie/{api-annotations-dotnet/tvOS-CoreMIDI.todo => watchOS-CoreMIDI.ignore} (93%) diff --git a/src/CoreMidi/MidiBluetoothDriver.cs b/src/CoreMidi/MidiBluetoothDriver.cs new file mode 100644 index 000000000000..fca10ececda5 --- /dev/null +++ b/src/CoreMidi/MidiBluetoothDriver.cs @@ -0,0 +1,49 @@ +// +// MidiBluetoothDriver.cs +// +// Authors: TJ Lambert (TJ.Lambert@microsoft.com) +// +// Copyright 2022 Microsoft Corp. +// + +#nullable enable + +using System; +using System.Runtime.InteropServices; + +using ObjCRuntime; +using CoreFoundation; +using Foundation; + +#if !NET +using NativeHandle = System.IntPtr; +#endif + +namespace CoreMidi { + +#if NET + [SupportedOSPlatform ("ios16.0")] + [SupportedOSPlatform ("maccatalyst16.0")] + [SupportedOSPlatform ("tvos16.0")] + [SupportedOSPlatform ("macos13.0")] +#else + [iOS (16,0), Mac (13,0), Watch (9,0), TV (16,0), MacCatalyst (16,0)] +#endif // NET + public partial class MidiBluetoothDriver { + [DllImport (Constants.CoreMidiLibrary)] + static extern int MIDIBluetoothDriverActivateAllConnections (); + + public static int ActivateAllConnections () + { + return MIDIBluetoothDriverActivateAllConnections (); + } + + [DllImport (Constants.CoreMidiLibrary)] + static extern unsafe int MIDIBluetoothDriverDisconnect (/* CFStringRef* */ NativeHandle uuid); + + public static int Disconnect (NSString uuid) + { + return MIDIBluetoothDriverDisconnect (uuid.GetHandle ()); + } + } +} diff --git a/src/coremidi.cs b/src/coremidi.cs index f2bbcf34fc71..7c468b508906 100644 --- a/src/coremidi.cs +++ b/src/coremidi.cs @@ -88,6 +88,7 @@ public enum MidiMessageType : uint { SysEx = 3, ChannelVoice2 = 4, Data128 = 5, + UnknownF = 15, } [Mac (11, 0), iOS (14, 0)] @@ -97,6 +98,8 @@ public enum MidiSysExStatus : uint { Start = 1, Continue = 2, End = 3, + MixedDataSetHeader = 8, + MixedDataSetPayload = 9, } [Mac (11, 0), iOS (14, 0)] @@ -116,6 +119,41 @@ public enum MidiSystemStatus : uint { SystemReset = 255, } + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [NativeName ("MIDINoteAttribute")] + public enum MidiNoteAttribute : byte + { + None = 0, + ManufacturerSpecific = 1, + ProfileSpecific = 2, + Pitch = 3, + } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [NativeName ("MIDIPerNoteManagementOptions")] + [Flags] + public enum MidiPerNoteManagementOptions : byte + { + Reset = 1 << 0, + Detach = 1 << 1, + } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [NativeName ("MIDIProgramChangeOptions")] + [Flags] + public enum MidiProgramChangeOptions : byte + { + MIDIProgramChangeBankValid = 1 << 0, + } + + [iOS (16,0), Mac (13,0), MacCatalyst (16,0)] + [NativeName ("MIDIUtilityStatus")] + public enum MidiUtilityStatus : uint + { + Noop = 0, + JitterReductionClock = 1, + JitterReductionTimestamp = 2, + } [NoTV][NoWatch] [Mac (10,15)] diff --git a/src/frameworks.sources b/src/frameworks.sources index cac8249068b2..c60462339709 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -597,6 +597,9 @@ COREMIDI_CORE_SOURCES = \ CoreMidi/MidiThruConnection.cs \ CoreMidi/MidiThruConnectionParams.cs \ +COREMIDI_SOURCES = \ + CoreMidi/MidiBluetoothDriver.cs \ + # CoreML COREML_SOURCES = \ diff --git a/tests/xtro-sharpie/api-annotations-dotnet/common-CoreMIDI.ignore b/tests/xtro-sharpie/api-annotations-dotnet/common-CoreMIDI.ignore index d86778797987..fcb5bd38d552 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/common-CoreMIDI.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/common-CoreMIDI.ignore @@ -74,3 +74,5 @@ !missing-pinvoke! MIDIReceivedEventList is not bound !missing-pinvoke! MIDISendEventList is not bound !missing-pinvoke! MIDISourceCreateWithProtocol is not bound +# introduced in Xcode13.3 but low level and cannot test without device +!missing-pinvoke! MIDIEventListForEachEvent is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreMIDI.todo b/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreMIDI.todo deleted file mode 100644 index a958ec5a7558..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreMIDI.todo +++ /dev/null @@ -1,10 +0,0 @@ -!missing-enum! MIDINoteAttribute not bound -!missing-enum! MIDIPerNoteManagementOptions not bound -!missing-enum! MIDIProgramChangeOptions not bound -!missing-enum! MIDIUtilityStatus not bound -!missing-enum-value! MidiMessageType native value kMIDIMessageTypeUnknownF = 15 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetHeader = 8 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetPayload = 9 not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound -!missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound -!missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreMIDI.todo b/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreMIDI.todo deleted file mode 100644 index a958ec5a7558..000000000000 --- a/tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreMIDI.todo +++ /dev/null @@ -1,10 +0,0 @@ -!missing-enum! MIDINoteAttribute not bound -!missing-enum! MIDIPerNoteManagementOptions not bound -!missing-enum! MIDIProgramChangeOptions not bound -!missing-enum! MIDIUtilityStatus not bound -!missing-enum-value! MidiMessageType native value kMIDIMessageTypeUnknownF = 15 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetHeader = 8 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetPayload = 9 not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound -!missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound -!missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/tvOS-CoreMIDI.todo b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.ignore similarity index 93% rename from tests/xtro-sharpie/tvOS-CoreMIDI.todo rename to tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.ignore index c8097253a84c..4b48354ec07e 100644 --- a/tests/xtro-sharpie/tvOS-CoreMIDI.todo +++ b/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.ignore @@ -1,3 +1,4 @@ +# CoreMIDI not supported for TV in Xcode14 !missing-enum! MIDICVStatus not bound !missing-enum! MIDIMessageType not bound !missing-enum! MIDINetworkConnectionPolicy not bound @@ -12,6 +13,5 @@ !missing-enum! MIDITransformControlType not bound !missing-enum! MIDITransformType not bound !missing-enum! MIDIUtilityStatus not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound !missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound !missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/common-CoreMIDI.ignore b/tests/xtro-sharpie/common-CoreMIDI.ignore index d86778797987..fcb5bd38d552 100644 --- a/tests/xtro-sharpie/common-CoreMIDI.ignore +++ b/tests/xtro-sharpie/common-CoreMIDI.ignore @@ -74,3 +74,5 @@ !missing-pinvoke! MIDIReceivedEventList is not bound !missing-pinvoke! MIDISendEventList is not bound !missing-pinvoke! MIDISourceCreateWithProtocol is not bound +# introduced in Xcode13.3 but low level and cannot test without device +!missing-pinvoke! MIDIEventListForEachEvent is not bound diff --git a/tests/xtro-sharpie/iOS-CoreMIDI.todo b/tests/xtro-sharpie/iOS-CoreMIDI.todo deleted file mode 100644 index a958ec5a7558..000000000000 --- a/tests/xtro-sharpie/iOS-CoreMIDI.todo +++ /dev/null @@ -1,10 +0,0 @@ -!missing-enum! MIDINoteAttribute not bound -!missing-enum! MIDIPerNoteManagementOptions not bound -!missing-enum! MIDIProgramChangeOptions not bound -!missing-enum! MIDIUtilityStatus not bound -!missing-enum-value! MidiMessageType native value kMIDIMessageTypeUnknownF = 15 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetHeader = 8 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetPayload = 9 not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound -!missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound -!missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/macOS-CoreMIDI.todo b/tests/xtro-sharpie/macOS-CoreMIDI.todo deleted file mode 100644 index a958ec5a7558..000000000000 --- a/tests/xtro-sharpie/macOS-CoreMIDI.todo +++ /dev/null @@ -1,10 +0,0 @@ -!missing-enum! MIDINoteAttribute not bound -!missing-enum! MIDIPerNoteManagementOptions not bound -!missing-enum! MIDIProgramChangeOptions not bound -!missing-enum! MIDIUtilityStatus not bound -!missing-enum-value! MidiMessageType native value kMIDIMessageTypeUnknownF = 15 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetHeader = 8 not bound -!missing-enum-value! MidiSysExStatus native value kMIDISysExStatusMixedDataSetPayload = 9 not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound -!missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound -!missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/watchOS-CoreMIDI.todo b/tests/xtro-sharpie/tvOS-CoreMIDI.ignore similarity index 93% rename from tests/xtro-sharpie/watchOS-CoreMIDI.todo rename to tests/xtro-sharpie/tvOS-CoreMIDI.ignore index c8097253a84c..4b48354ec07e 100644 --- a/tests/xtro-sharpie/watchOS-CoreMIDI.todo +++ b/tests/xtro-sharpie/tvOS-CoreMIDI.ignore @@ -1,3 +1,4 @@ +# CoreMIDI not supported for TV in Xcode14 !missing-enum! MIDICVStatus not bound !missing-enum! MIDIMessageType not bound !missing-enum! MIDINetworkConnectionPolicy not bound @@ -12,6 +13,5 @@ !missing-enum! MIDITransformControlType not bound !missing-enum! MIDITransformType not bound !missing-enum! MIDIUtilityStatus not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound !missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound !missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound diff --git a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.todo b/tests/xtro-sharpie/watchOS-CoreMIDI.ignore similarity index 93% rename from tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.todo rename to tests/xtro-sharpie/watchOS-CoreMIDI.ignore index c8097253a84c..4698dfa1932f 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/tvOS-CoreMIDI.todo +++ b/tests/xtro-sharpie/watchOS-CoreMIDI.ignore @@ -1,3 +1,4 @@ +# CoreMIDI not supported for watch in Xcode14 !missing-enum! MIDICVStatus not bound !missing-enum! MIDIMessageType not bound !missing-enum! MIDINetworkConnectionPolicy not bound @@ -12,6 +13,5 @@ !missing-enum! MIDITransformControlType not bound !missing-enum! MIDITransformType not bound !missing-enum! MIDIUtilityStatus not bound -!missing-pinvoke! MIDIEventListForEachEvent is not bound !missing-pinvoke! MIDIBluetoothDriverActivateAllConnections is not bound !missing-pinvoke! MIDIBluetoothDriverDisconnect is not bound From 5d90f79254bd81f9678df3ecfda305864da2038a Mon Sep 17 00:00:00 2001 From: TJ Lambert Date: Fri, 9 Sep 2022 11:27:16 -0500 Subject: [PATCH 2/2] clean up a little --- src/CoreMidi/MidiBluetoothDriver.cs | 10 ++-------- src/coremidi.cs | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/CoreMidi/MidiBluetoothDriver.cs b/src/CoreMidi/MidiBluetoothDriver.cs index fca10ececda5..8cb9dd56fe99 100644 --- a/src/CoreMidi/MidiBluetoothDriver.cs +++ b/src/CoreMidi/MidiBluetoothDriver.cs @@ -33,17 +33,11 @@ public partial class MidiBluetoothDriver { [DllImport (Constants.CoreMidiLibrary)] static extern int MIDIBluetoothDriverActivateAllConnections (); - public static int ActivateAllConnections () - { - return MIDIBluetoothDriverActivateAllConnections (); - } + public static int ActivateAllConnections () => MIDIBluetoothDriverActivateAllConnections (); [DllImport (Constants.CoreMidiLibrary)] static extern unsafe int MIDIBluetoothDriverDisconnect (/* CFStringRef* */ NativeHandle uuid); - public static int Disconnect (NSString uuid) - { - return MIDIBluetoothDriverDisconnect (uuid.GetHandle ()); - } + public static int Disconnect (NSString uuid) => MIDIBluetoothDriverDisconnect (uuid.GetHandle ()); } } diff --git a/src/coremidi.cs b/src/coremidi.cs index 7c468b508906..a33517d4aa32 100644 --- a/src/coremidi.cs +++ b/src/coremidi.cs @@ -143,7 +143,7 @@ public enum MidiPerNoteManagementOptions : byte [Flags] public enum MidiProgramChangeOptions : byte { - MIDIProgramChangeBankValid = 1 << 0, + BankValid = 1 << 0, } [iOS (16,0), Mac (13,0), MacCatalyst (16,0)]