Closed akshayabd closed 11 months ago
Hi,
Unfortunately I have no Apple devices, so I won't be able to do tests on my side. So I really need your help with the issue.
Well, first of all, download please the ReceiveMidiData utility for macOS from here. Run it (in Terminal for example), select the same device and tell me please if the same error occurs.
Also what if you try to receive data from another MIDI device? Do you see the same error?
And one more question: do you have Visual Studio for Mac installed? I suppose we'll need to debug the library on your side.
Thanks, Max
Oh wait, I've just noticed a problem in your code:
if (inputDevices.Count > 0)
{
InputDevice _inputDevice = inputDevices.First();
You create local variable here which will be collected by GC when the method exits. So in OnEventReceived
the _inputDevice
is probably deleted. You need to declare _inputDevice
as a class field, not as a local variable. And I suppose the problem will gone. See an example here: https://melanchall.github.io/drywetmidi/articles/devices/Input-device.html.
Ah such a silly mistake - thanks for pointing that out!
Confirmed when I use a class field the issue doesn't occur. Odd it worked on Windows, maybe the GC behavior is different there.
Hi,
I'm using DryWetMIDI to process inputs from MIDI devices like an electric keyboard in a Unity project. I'm using the Unity asset available to do this.
Things work on a Windows machine, however when I try running on a MacBook it crashes fairly quickly with the following stacktrace:
I was wondering if you have encountered this before and if there is a solution for this?
I'm getting the connected device using the following code:
Then I'm handling the events in a method with the signature:
If you need more information please let me know, I can perhaps create a minimal project and share it on GitHub.