Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MIDISetup - add/remove device. Missing tests.
  • Loading branch information
rolfbjarne committed Jun 4, 2025
commit c36ed6b1b0e47dd660c704c4f4f68872a0048636
24 changes: 24 additions & 0 deletions src/CoreMidi/MidiServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,32 @@ public static nint DeviceCount {
#endif // !COREBUILD
}

/// <summary>This class consists of functions that customize the global state of the MIDI system.</summary>
public static class MidiSetup {
#if !COREBUILD
[DllImport (Constants.CoreMidiLibrary)]
unsafe extern static OSStatus MIDISetupAddDevice (MidiDeviceRef device);

/// <summary>Add a device to the current MIDI setup.</summary>
/// <param name="device">The device to add to the current MIDI setup.</param>
/// <returns>A status code that describes the result of the operation. This will be <see cref="MidiError.Ok" /> in case of success.</returns>
public static MidiError AddDevice (MidiDevice device)
{
return (MidiError) MIDISetupAddDevice (device.GetCheckedHandle ());
}


[DllImport (Constants.CoreMidiLibrary)]
unsafe extern static OSStatus MIDISetupRemoveDevice (MidiDeviceRef device);

/// <summary>Remove a device from the current MIDI setup.</summary>
/// <param name="device">The device to remove from the current MIDI setup.</param>
/// <returns>A status code that describes the result of the operation. This will be <see cref="MidiError.Ok" /> in case of success.</returns>
public static MidiError RemoveDevice (MidiDevice device)
{
return (MidiError) MIDISetupRemoveDevice (device.GetCheckedHandle ());
}

[DllImport (Constants.CoreMidiLibrary)]
unsafe extern static OSStatus MIDISetupAddExternalDevice (MidiDeviceRef device);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
!missing-pinvoke! MIDIGetDriverDeviceList is not bound
!missing-pinvoke! MIDIGetDriverIORunLoop is not bound
!missing-pinvoke! MIDISendSysex is not bound
!missing-pinvoke! MIDISetupAddDevice is not bound
!missing-pinvoke! MIDISetupRemoveDevice is not bound

# same as the above, we should bind all of them, these have been added on Xcode 12 beta 2
# https://github.com/dotnet/macios/issues/4452#issuecomment-660220392
Expand Down
2 changes: 0 additions & 2 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreMIDI.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
!missing-pinvoke! MIDIGetDriverDeviceList is not bound
!missing-pinvoke! MIDIGetDriverIORunLoop is not bound
!missing-pinvoke! MIDISendSysex is not bound
!missing-pinvoke! MIDISetupAddDevice is not bound
!missing-pinvoke! MIDISetupRemoveDevice is not bound

# same as the above, we should bind all of them, these have been added on Xcode 12 beta 2
# https://github.com/dotnet/macios/issues/4452#issuecomment-660220392
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
!missing-pinvoke! MIDIGetDriverDeviceList is not bound
!missing-pinvoke! MIDIGetDriverIORunLoop is not bound
!missing-pinvoke! MIDISendSysex is not bound
!missing-pinvoke! MIDISetupAddDevice is not bound
!missing-pinvoke! MIDISetupRemoveDevice is not bound

# same as the above, we should bind all of them, these have been added on Xcode 12 beta 2
# https://github.com/dotnet/macios/issues/4452#issuecomment-660220392
Expand Down