Hi We're a small team working to interface Puredata with Unity (http://puredata.info/). We have a working bridge: Code (csharp): using UnityEngine; using System; using System.Runtime.InteropServices; public class ZGUnity : MonoBehaviour { [DllImport ("ZGUnity")] private static extern IntPtr zg_new_context(int numInputChannels, int numOutputChannels, int blockSize, float sampleRate, long function, long userData); [DllImport ("ZGUnity")] private static extern IntPtr zg_new_graph(IntPtr context, string directory, string patch); [DllImport ("ZGUnity")] private static extern void zg_attach_graph(IntPtr context, IntPtr graph); [DllImport ("ZGUnity")] private static extern void zg_process(IntPtr context, float[] inputBuffer, float[] outputBuffer); [DllImport ("ZGUnity")] private static extern void zg_delete_context(IntPtr context); const int numInputChannels = 2; const int numOutputChannels = 2; const int blockSize = 256; const float sampleRate = 44100.0f; float[] inputBuffer = new float[blockSize * numInputChannels]; float[] outputBuffer = new float[blockSize * numOutputChannels]; IntPtr zgContext; IntPtr zgGraph; void Awake() { zgContext = zg_new_context(numInputChannels, numOutputChannels, blockSize, sampleRate, 0, 0); zgGraph = zg_new_graph(zgContext, "/Users/dpc/Desktop/", "simple_osc.pd"); zg_attach_graph(zgContext, zgGraph); } void Update() { zg_process(zgContext, inputBuffer, outputBuffer); Debug.Log(outputBuffer[0]); } } But, now we need to pass the audio buffer (outputBuffer) to Unity's own audio session...I've read a few examples including Prime31's AudioRecorderBinding and some Objective-C code, but I'm stumped that there isn't a clear way to just pass audio samples into Unity's engine...am I wrong? Does anyone know of a way we could do this simply? David
Hi, Audio buffer access is not available now (and in 3.0). We are aware that this is one of the most wanted audio features - and we are working on it. But again, we want to do it "the right way" to ensure low latency, while still interfacing Mono (think GC, threads etc.) If you're running standalones you can use the FMOD plugin from http://www.squaretangle.com/FMODUnity.html.
Thankyouthankyouthankyou for replying and letting us know! Phew, such a relief to know you're working on access to audio buffers. Just so you know, we're (today/tomorrow) interfacing Puredata to RemoteIO to be able to use zengarden (puredata runtime lib) in Unity through the c# layer. We can already pass data back and forth, but being able to make puredata audio point sources to, say, and AudioListener, would be fantastic (3d positioning, etc.). I have to ensure we can target iOS, so squaretangle's work won't help here (or will it?). Thanks again for listening, can't wait to see what you do. We're aware low latency and audio clock timing is not easy. Good luck! David
Just for those still interested, we have a working bridge for Unity-Puredata (iOS and Android) on github: https://github.com/hagish/kalimba. Cheers, FBP
Thank you so much for kalimba, i was wondering if it works with unity webplayer or not? or is it only for smartphone? Thanks again Fbp, and continue the great work
I'm interested in this too... has anyone used Pure Data in a Unity project, that we might be able to hear in action?