Open ablanton opened 6 years ago
In looking at it now, I think it needs both definition in UnityPD.cs and a level lower for each platform. For instance this would need to be added to the iOS library, correct?
What data bindings are you looking to get back from Pd? Marking methods in C# as callbacks for Pd messages?
If so, yes, you'll need to make a couple extra methods in the C++ code (have a look near the bottom of Plugin_UnityPd.cpp
for examples of the other methods that C# calls)
With those you can call the libpd bind methods and register a callback to Unity code with UnitySendMessage (this may cause issues if it blocks PD while it tries to call c# code, I'm not sure how it's implemented)
Thanks for the response! I think I'm getting close, libPd has bindings for message, float, and bang and those three would be great to get back.
So for instance in the Plugin_UnityPd.cpp, would something like this work:
extern "C" UNITY_AUDIODSP_EXPORT_API void UnityPd_RecieveSymbol( const char sender, const char message ) { mtx.lock(); libpd_symbol(sender, message); mtx.unlock(); }
libpd_symbol is used for sending messages to Pd (which is already supported) You'll need to use the binding methods to tell Pd that your C code should get callbacks when data is sent to the symbol you're interested
AFAICT those callbacks are global and you just make one for each type of message Pd sends. I've already made one for the print hook (see pdprint
and where I hooked it in), but you'll need to make one for the other data types. In those you probably just want to pass the message/data up to Unity.
It might even make sense to have the C code register a symbol at startup without Unity telling it to first (say, make UnityPD listen to all messages sent with s unity
) and just pass them all up to Unity code to be dealt with in C#.
This would be really amazing. Would it require to rebuild from source to be able to achieve this?
Yes, there is currently no way to add new communications from C# to Pd without adding some (small) code to the C plugin, though the libPD/PD libraries don't need to be rebuilt. I haven't tried with the newer Xcodes, but the project as is should still build by following the instructions in the readme.
Hi all,
This is an amazing repo and it works very well. I was trying to expose the data bindings to send data back from pure data. I was thinking that would happen in UnityPD.cs but a friend of mine was saying that it potentially needed to happen a level deeper. Have you looked at doing this, of could I help in trying to get this working? It would be so awesome!!