Pure Data Integration - help!

Dear Unity community,

As a former composer of notated music with some experience having used Pure Data for Live Electronics, I’ve found the program to be extremely flexible for creating stochastic (algorithmic) music. It can also be used to transform sound in any way imaginable while reacting live to audio or data input. As my interest in sound-design for games grew, I was excited by the possibility of incorporating PD into Unity, as it would allow for music whose various paramaters are transformed in accord with player input. This has already been done by some developers (e.g. the makers of Bad Hotel and Fract) via libpd, a „wrappable“ version of the software. And yet, I find myself unable to make any of the available plug-ins work, even with the aid of a programmer, Slayther.

I’m very desperate to have PD work in Unity, as it’s by far the program I know (and like) best. Here is a summary of two of the available plug-ins and their reported errors. Any insight is appreciated:

libpd4unity (Patrick Sebastien)

https://github.com/patricksebastien/libpd4unity

Article on Sebastian’s plug-in

Slayther: First, I tested libpd[4unity] without compiling the extensions

As with uPD (see below), slayther tried the 32-bit Unity 5 editor:

Slayther: Which is strange, because when I checked the code, it indeed can take 2 arguments

Slayther: The second error is also odd

Next, Slayther tried libPD4unity in Unity 4 and discovered different errors:

Slayther: But sound can be heard. Playing for the second time, however, crashes the Unity.So some stuff have been fixed in Unity 5, it seems.

uPD (Magicolo)

https://github.com/Magicolo/uPD

Slayther: As uPD is using libpd itself, it’s expected to throw same error [as libpd4unity]

I tried searching for how to compile 64 bit extension with MinGW, but couldn’t find anything

After I suggested that slayther try it in the 32-bit editor, to isolate the problem, slayther reported some strange bucks and that only one of the test scenes worked. He reported

Slayther: It says libpd isn’t compatible with Unity Webplayer

Next, Slayther tried uPD in Unity 4 and discovered different errors:

Current status

I’ve done some searching in this forum and elsewhere and have found some results for MaxMSP/PD integration (including a plug-in called Kalimba which we’re going to test soon, although it was intended for Unity Mobile). The general problem is that most of these results are a few years old and there doesn’t seem to be much current work being done on PD integration, which apparently was successful at some point but has deprecated due to the evolving Unity software. The people involved are also hard to reach. I heard from Magicolo on a PD forum 8 months ago but not since. Of course, I haven’t given up yet.

Thanks in advance,
Elliot

Hey Elliot,

I’ve had bad luck as well getting libpd to work with Unity. I was able to get Patrick’s solution to work in Unity 4.6 (32bit editor pro ) and that was with his already compiled dll he provided in the project. That said, a few months a go I tried to get it working in Unity 5 with no luck. I tried compiling libpd myself and was able to get the dll compiled just fine with no errors but the 64 bit version does not with Unity 5. After that I gave up sense I needed to get it to work with the 64 bit editor. Sniffing around the libpd issues on github, there is an open ticket about getting the 64bit dll to work on Windows but they do not have a dedicated windows developer so that one probably won’t get touched for quite some time if at all. C# 64bit DLL compilation · Issue #110 · libpd/libpd · GitHub

Anyway, here’s the most promising pd related tool I’ve seen so far that’s still being updated Loading... It’s very sound designer friendly and it doesn’t assume your an audio programmer!

It’s called Heavy and you create an account and upload pd patches then it generates a usable plugin and a C# interface for you to use for Unity. I was not able to get the Unity 5 mixer plugins to work sense I’m on Windows 7 which is a bug they highlighted in their documentation.

If that doesn’t work out for you, your going to have to decide how much time you want to spend trying to get this to work. The really frustrating part about working with open source stuff is you have to do so much work and debugging to get a solution up and running. Personally I gave up on the whole matter sense I didn’t need to have a pd implementation and it was far too much work for what I would be using it for.

Another useful thing to check out (not an alternative) is this extension of the audio mixer. The demo project contains useful examples of procedural audio and music. Also gives you the full source code for writing audio effects for the mixer. Unity - Manual: Native audio plug-in SDK

Hope that helps and good luck!

-Andrew

1 Like

Thanks, Mr. Benz. I greatly appreciate your help. Yes, Mr. Sebastien got back to me with a fix for Unity 4, but he hasn’t tried his plug-in with Unity 5 yet.

In any case, that “Heavy” tool looks great and I’m going to try it soon. EDIT: But if this list of objects is for “Heavy”, I’ll have a problem: Loading... Looks like they have their own library of abstractions: GitHub - enzienaudio/heavylib: Library of Heavy compatible abstractions

Excellent, glad I could be helpful! Maybe that new fix from him will work in Unity 5? It could work with the 32bit editor… As far as what I’ve seen people only have a problem with the 64bit dlls of libpd.

And yeah there are drawbacks with Heavy which sounds like it could be a deal breaker for ya. The developers seem pretty responsive so you might be able to put in a request for specific objects you need.

I’d be interested to see hear if you get a solution up and running!

Hi everyone!

So if you’ve been having trouble generating the 64bit dll for libpd I think I might have stumbled on the solution. The original example has a dependency on another dll called ‘pthreadGC2.dll’, the 64bit has no such dependency and instead is dependent on ‘libwinpthread-1.dll’. If you run the batch file to make your new 64bit dll, you’ll need to pull both the libpdsharp.dll AND the libwinpthread-1.dll file and stick those in you Unity Assets/Plugins folder. From there it works in 64bit no problem.

I hope this helps someone, as this solution took me all day to figure out.