atsushieno / managed-midi

[Past project] Cross-platform MIDI processing library for mono and .NET (ALSA, CoreMIDI, Android, WinMM and UWP).
MIT License
194 stars 26 forks source link

Integration in Unity #54

Open ankushmp opened 4 years ago

ankushmp commented 4 years ago

Hi

Just wanted to confirm few things:

  1. Can i Integrate this library in Unity3D?
  2. I want to take input from the Yamaha Piano to unity application and then deploy that application in Hololens 1(UWP). Will it work?
  3. Is there anything else needs to import along with this library.
  4. Also which library should i integrate in my Unity project for Hololens 1?

Thanks in advance.

atsushieno commented 4 years ago
  1. The answers are complicated:
  1. I never thought that Unity could support UWP, which actually seems possible. If that's the case, the answer is most likely NO if you expect built-in support, but likely YES if you can write code to fill the gap (either as a new code or making changes to existing managed-midi code).

  2. managed-midi has subsequent dependency to my alsa-sharp library, but it is used only on Linux. And those native frameworks per platform-specific implementation assembly (e.g. Mono.Android.dll for Android implementation), but nothing else.

4, To my understanding Hololens can be backed only by UWP when it comes to frameworks that managed-midi supports.

pschon commented 4 years ago

Seems like it should work, after removing bunch of stuff that I didn't need I got it to compile and run with Unity.

Works perfectly on Windows, on Linux I get an error about not finding asound.dll when trying to play but no compile errors etc so once i get that missing dll sorted out seems like it's all good for developing and running on Linux as well.

(I'm using this instead of the more common MIDI plugin from Keijiro since i need MIDI out as well for my project. And Linux build support of course ;))

atsushieno commented 4 years ago

asound.dll should be actually libasound.so which is ALSA that managed-midi calls via P/Invoke methods on Linux. On Windows native shared libraries are DLLs, so those .NET-ish runtimes would have reported missing shared libraries as missing DLLs (I only know mono/mono and it does not report like "dll", but Unity-Technologies/mono may be different).

Typically those missing libraries be indicated to point to the actual shared libraries using <dllmap> configuration item. libasound.so can be found in the system directory like /usr/lib/x86_64-linux-gnu/libasound.so.2.0.0 or whatever you have on your system or whatever libasound development package (e.g. libasound2-dev on my Ubuntu desktop) provides. Having LD_LIBRARY_PATH to include that lib path might work too.

pschon commented 4 years ago

ok, that was a quick response! Thanks very much, found the file, sadly LD_LIBRARY_PATH didn't work so I'll need to dig around a bit to figure out how to get Unity to load it, but at least I'm making some progress again!

(And in the worst case I can always just build&run on Windows, getting it working on Linux is just a personal preference and with a game designed to be played on a specific MIDI controller it's not like I'd really need to worry about other people being able to run it anyway)

JuanuMusic commented 4 years ago

I was planning on using it on Unity as well. Maybe we can work together on creating the Unity implementations for each platform?

atsushieno commented 4 years ago

My interest is not on .NET anymore and no plan to learn Unity so far, but I can spare some time on it and would be able to help your effort.

So far my understanding on Android part is that UnityEngine has quite similar set of JNI support features to that of Xamarin.Android (namely Java.Interop). Things could become easier if we can replicate Xamarin.Android API but for Unity (otherwise it will be a bunch of JNI wrapper calls in hand-binding code).

atsushieno commented 4 years ago

For those who want to use MIDI input support on Unity, there is https://github.com/keijiro/Minis now.