Open jamesdlow opened 1 year ago
I've tried wrapping in a Device.BeginInvokeOnMainThread
incase that helped, but it didn't.
I've also double-checked, I can receive MIDI from my device.
Ok, so if I set length to 0, i.e. output.Send(new byte[] { MidiEvent.NoteOn, 0x40, 0x70 }, 0, 0, 0);
there is no error, but this sends no MIDI data. But may help in debugging the exception, since it may be that for whatever reason the length of an array further down is 0. Is it when it's being copied in System.Runtime.InteropServices.Marshal.Copy
?
I think I've tracked it down to an issue with xamarin/xamarin-macios https://github.com/xamarin/xamarin-macios/pull/18981
A workaround would be to switch:
new MidiPacket(timestamp, (ushort)length, (IntPtr)(ptr + offset));
to
new MidiPacket(timestamp, mevent, offset, length)
in CoreMidiAccess.cs
public void Send (byte[] mevent, int offset, int length, long timestamp)
{
unsafe {
fixed (byte* ptr = mevent) {
arr [0] = new MidiPacket(timestamp, (ushort)length, (IntPtr)(ptr + offset));
port.Send (details.Endpoint, arr);
}
}
}
There are other constructors for MidiPacket that don't use pointers: https://learn.microsoft.com/en-us/dotnet/api/coremidi.midipacket.-ctor?view=xamarin-ios-sdk-12
I'm getting an error when I try to execute the sample code on macOS. I've tried running on iOS and it errors too. I've debugged and the output exists and I have its name/id. Any idea what the issue is?
Message:
The exception is a
System.ArgumentException
Stacktrace:
Code: