Transmitting MIDI events from JUCE app to Unity3D app


#1

I'm planning to use Unity3D to make visualisations, so my JUCE app emits noteOn&offs and my Unity app receives them.

Can anyone see a good way of doing this?

I'm imagining using localhost sockets and wiring a port, then using UDP -- slightly dreading it TBH as I find socket programming slippery, there doesn't seem to be any good learning resource.

If anyone has dealt with the same kind of scenario, some kind of overview would be really appreciated!

π

PS I may end up doing sections of the UI (or maybe the whole thing) in Unity, I should find some solution that supports bidirectional Communication. Eventually I will look at integrating, but I know that's going to be headache, and I can make better R&D tools by keeping components separate.


#2

Easy to do if you're on os x!

https://www.juce.com/doc/classMidiInput#af6053fd48f64d92cb2efb54c266d10c5

https://www.juce.com/doc/classMidiOutput#a04169caa4a0c533c57a55357f2e13cc8


#3

I'm going to go for a multiplatform solution.

I think I can ignore the fact that it is MIDI, I can just send raw packets containing {MIDI note, velocity}

https://github.com/julianstorer/JUCE/tree/master/modules/juce_osc/osc <-- this looks promising.

π


#4

Or maybe the InterprocessConnection class would work? https://www.juce.com/doc/classInterprocessConnection


#5

I'd go for JUCE's OSC in the C++ part and a .NET OSC implementation Unity.

With a little luck the implementation you choose does not do anything that Unitys iOS export does not like ( jit! ) and it will "just work" out of the box on all platforms.

https://github.com/ValdemarOrn/SharpOSC was the first hit that came up and it looked alright from a quick glance.

I worked with both, Unity & JUCE during the last years, and I'd try avoiding making a native plugin for unity that contains the JUCE code. It's certainly doable, but you better have a good reason to jump through all the hoops - probably not worth it for something as simple as sending MIDI data over UDP. 

Best,
Ben


#6

I'd agree with beschulz as the best solution.

But if you want some code, I have some old (read as "not very tidy" smiley) code that works using TCP to set up a connection between Unity and a JUCE app. I've been using it for the past six years or so to help teach game audio and game audio programming. TCP seems fast enough even to report rapid machine gun fire events and multiple game objects dynamically moving in space and keep good timing. I always had it as a "to do" to convert it to UDP although I'd go the OSC route now.


#7

OSC!! :D

So glad that's in JUCE now.  


#8

Thanks for the offer!

After sleeping on it, I've decided to use JUCE for my GUI at least until I have a prototype ready, as using Unity introduces a bunch of headaches.

π