Search Unity

Midi Support API

Discussion in 'General Discussion' started by KliveOne, Jan 10, 2018.

  1. KliveOne

    KliveOne

    Joined:
    Jul 28, 2015
    Posts:
    25
    Hellos, I cannot seem to figure out if Midi can be utilized in Unity 3D.

    Every Google search I run into seems to lead me to a 2014 thread where it was going to possibly become a thing used in Unity.
    I realize that is 2014 and things may be different now.

    My main question or thing Im looking to do is pretty much control Midi ports(?) via Unity and script them to buttons. An example would be making a Midi controller (keyboard or synth) and use the Android option of linking USB via a Midi protocol to well, be a midi controller :)

    The Unity API website doesnt show or return any results when it comes to Midi in general.

    Can someone assist me with this?
     
  2. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Unity was all ready to add MIDI. If you notice in that thread a bunch of luddites who had no use for it in their non developing of games popped up just to nix it, the Unity tech dev disappeared and we are stuck with the results of some luddite whiners whose basic interface with Unity is to post to these forums all day.
     
    sinjinn, code-blep and Astirian like this.
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,155
    Just like they're all ready to add new terrain and input systems? The thread in question was about gauging interest in it but realistically Unity takes forever to reach a release stage so even if they have a prototype it's likely stuck in development hell with the two previously mentioned systems.

    If you're looking to use a physical midi device, you might have luck with this asset, but I haven't tried it myself.

    https://www.assetstore.unity3d.com/en/#!/content/85256
     
    Last edited: Jan 11, 2018
  4. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Bought the asset for version 4.x and the dev was extremely unhelpful and there was no documentation. It is basically a wrap of the open source MIDI libraries out there.
     
    Ryiah likes this.
  5. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,155
    Thanks for letting us know. That definitely explains the rating it has.
     
  6. KliveOne

    KliveOne

    Joined:
    Jul 28, 2015
    Posts:
    25
    Lol thanks guys , yes that was the thread I kinda was a bit 'wow' with looking at all the comments. Unity can be used for apps, I understand its a game engine but I guess creativity can cause something it wasnt 'intended' for to be used in other designs.

    However I was looking for the reverse of what you said Ryiah. In a nutshell (ll figure out the rest) I want to do something like this.

    https://play.google.com/store/apps/details?id=com.mobileer.midikeyboard&hl=en

    Only with a rearrangement of buttons,

    I know this wasnt done in unity and was done in Java (according to his github), but curious no less.

    Bascailly a Usb Midi controller on the Android that can send midi commands to windows where I go from there.

    Overall a function or set , heck even a call method to route a clicked button into midi outputs to a PC.


    If not any idea where I can start?
     
  7. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    I know for sure keijiro has done midi handling stuff with unity before somewhere in his gold mine of awesome mini projects he does with the engine.
     
  8. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I like Keijiros stuff and use their midi things all the time ( eg https://github.com/keijiro/MidiJack ) . But they are only for midi-in, and not for android, so they wont meet KliveOne's requirements.
     
    Ryiah likes this.
  9. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I used this asset and I did get it working ok but didnt like the documentation/translation issues and I totally stopped using it due to their paid upgrade strategy when it came to supporting newer unity versions etc.

    However if I really needed midi out, and platform support such as Android, and quickly, then I probably wouldnt hesitate to use it again.
     
    Ryiah likes this.
  10. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Well, the primary issue with Midi support is it's dependence on hardware for actual audio rendering. The hardware you use to play Midi files directly affects how those midi files will sound. It is entirely possible to improve the audio playback of midi files by acquiring better, more expensive playback tech, like more advanced audio cards.

    This specific hardware support makes the format a little less useful for a platform-agnostic game engine. For somewhat similar features, I recommend looking into Mod-Trackers, which are currently supported by Unity's audio system. Sadly, they are a bit less useful when it comes to dynamic music. But for music composed beforehand they should provide you with a bit more of the midi-style feature set, with much smaller file sizes and the possibility for much longer tracks.
     
    kbitikofer likes this.
  11. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,144

    I'm pretty sure the OP is talking about MIDI as a digital interface, not as an audio playback system.
     
    SYFGreatman and angrypenguin like this.
  12. KliveOne

    KliveOne

    Joined:
    Jul 28, 2015
    Posts:
    25
    Yes what Murgilod said. Im not trying to render any audio whatsoever. I simply had the idea when I saw the app created to use a similair setup to utilize what was 'heard' in windows.

    I was playing around even more and found a program that does pretty much what I was assuming. Called "HID Macros" This is literally what im trying to accomplish. To 'hear/listen' the Midi outputs from an android app into this program, which did hear them and I was able to (in this case) route a button push on the app to a windows key. IE: Push app button > press enter in pc.

    Love the idea and wanted to try my hand at creating a mini personal ap that controlls various things I do on the pc. Say push app button > open program , etc. The ideas can go wild with it. Just wanted to tinker around :)

    Because sadly seems doing this without (at least midi) i need a 'rooted' android and this app,program combo does it without the need to root :p
     
  13. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,155
    Unless you eventually plan to hook up an actual hardware MIDI device (eg a keyboard), you'll have a much easier time with some form of networking (eg Unity's LLAPI). You basically would have a program running on the PC waiting for commands from another program that runs off the Android device.

    https://docs.unity3d.com/Manual/UNetUsingTransport.html
    http://www.robotmonkeybrain.com/good-enough-guide-to-unitys-unet-transport-layer-llapi/
     
  14. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    I think you'll need to write a wrapper for native midi interface, which will be different for each platform (and some platforms won't have it).

    For example, here's a stackoverflow thread for interfacing with MIDI in C#:
    https://stackoverflow.com/questions/1991159/getting-signals-from-a-midi-port-in-c-sharp

    However, tha'ts for windows platform.

    For android there are those pages:
    https://source.android.com/devices/audio/midi
    https://www.midi.org/articles/android-midi-in-marshmallow

    Apparently it may be tricky, because in some circumstances it needs to be enabled at kernel level.

    Overall, it looks like thsi is the situation which will require you to write your own native plugin - with version fo every platform.
     
  15. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,155
    Just stumbled upon this wrapper. Supports standalones (Windows, macOS, Linux) as well as mobile (Android, iOS, UWP) but they do mention that some of them (macOS, iOS, UWP) have yet to be tested. Fortunately none of those are needed.

    https://github.com/atsushieno/managed-midi
     
    neginfinity likes this.
  16. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    This actually looks like it could be good. It is also available under mit license.
     
  17. TeotiGraphix

    TeotiGraphix

    Joined:
    Jan 11, 2011
    Posts:
    145
    I'm going to try this library in a while, I will report back on this thread if I have any luck.

    I am targeting Windows and Android for this.
     
    pleksus likes this.
  18. pl3ksus

    pl3ksus

    Joined:
    Feb 27, 2013
    Posts:
    2
    Any luck?

    I've been using midi-dot-net for Windows Midi Out until now. But with 2019.1 deprecating .Net 3.5, that's not an option anymore. Very much interested in alternatives.
     
  19. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Ah Midi, the good old days, my friends was on FM synthesizer cards like Adlib and Soundblaster and I had a Roland :D
     
  20. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    I don't think this is how scripting api deprecation works. .Net 4x is backward compatible for the most of the part.
    I doubt you'll run into issues with that.

    If you do, its an open source project. Just open the lib and fix the issues that would come along.
     
  21. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    As far as I understand it's only the "old days" for consumer-oriented audio playback. I believe that as an interface protocol it's still used quite a bit in professional scenarios.
     
  22. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Yepp, it can also be used for gaming. My software Freepie has midisupport and I know its used to control games



     
  23. KillerPlankton

    KillerPlankton

    Joined:
    Jul 14, 2020
    Posts:
    3
    Hi KliveOne, did you resolve your issue. I'm having the same problem. When I'm using Unity Remote on my cell phone I can use it to send midi but when I'm building the app and then the app is on my cell and not my computer, I don't how to send midi message :(. I basically want to do the same thing as you ^^
     
  24. GordH

    GordH

    Joined:
    Jan 28, 2021
    Posts:
    2
    I used Touch OSC on an iPad to control derivative Touch Designer on a PC successfully. You might check out this link:
    https://hexler.net/products/touchosc

    Hope this helps.
     
  25. adayal2016

    adayal2016

    Joined:
    Jan 11, 2022
    Posts:
    6
    Hi,

    Wondering if there have been any updates on this?

    I would like to be able to interact with MIDI devices and handle MIDI input events in Unity on the iOS platform. Does anyone have experience with this?
     
    Unifikation likes this.
  26. matthewkgreene

    matthewkgreene

    Joined:
    Nov 10, 2015
    Posts:
    2
    Ever find a solution? I'm in the same boat.
     
  27. sonicdesordre

    sonicdesordre

    Joined:
    May 31, 2021
    Posts:
    11
    Is there any good Midi asset you could recommend , which works out of the box ( no .dll issues, no installation problems ) and it should deliver the incoming midi messages of all kinds and also be able to send them to existing ports. ? And of course cross platform support, at least OSX, Windows and iOS.