playdots / UnityPd

Procedural audio generated using unity.
MIT License
55 stars 6 forks source link

UnityPd

Procedural audio for Unity, generated using Pure Data

Based on libpd https://github.com/libpd/libpd which is an embeddable version of pure-data https://github.com/pure-data/pure-data which is a tiny audio synthesis library

This project builds Unity Native Audio http://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html plugin versions of libpd, and provides the bindings for some common functions.

How 2 Build

This is distributed with pre-built release binaries inside UnityPd/Platform, but if you want to build yourself, follow these steps to replace them

iOS & OSX

libPD & Unity native audio plugin

Open XCode project in src/Xcode iOS Switch target to AudioPlugin_UnityPd_iOS, Destination to Generic iOS device For OSX Switch target to AudioPluginDemo, Destination as default

Build to archive to make release version of plugin. If you do this, remember to get the plugin out of the archive, since it won't be copied to UnityPd/iOS like normal

Android (arm & x86)

libPD & Unity native audio plugin

Get the JDK! http://developer.android.com/intl/es/tools/sdk/ndk/index.html

cd src/Android ndk-build (or ndk-build DEBUG=true for a debug enabled .so)

UnityPdAndroidHelper

Android also neeeds an additional jar to help Pd with its crazy file system Get Ant if you don't have it already!

cd src/UnityPdAndroidHelper ant jar

Windows

Sorry, I couldn't get libpd working on Windows with my limited Windows knowledge. But there currently is a dummy plugin + bindings so that developers can work on windows (just with no Pd)

How 2 Add 2 Unity

Copy the UnityPd folder into your project's Plugins folder. Unity should be smart enough to set up all the plugins for each platform, but check that each Plugin is only enabled on the appropriate platform if you have issues.

Add an Audio Mixer Group to your project if you haven't already, and then a UnityPD effect to a mixer. If you want to purely generate sound with Pd, make sure to turn Auto Mixer Suspend on the Mixer Group to make sure Pd keeps receiving process calls even when no sounds are being generated.

iOS

Unity on iOS needs to load the plugin when the app starts up. To do this you need to edit the UnityAppController.mm file:

Alternatively, you can override AppController, see the example project Assets/Plugins/iOS/UnityPdAppController for an example

How 2 Use

UnityPD functions are all defined in UnityPd.cs. Currently only simple bindings are included:

Messages

(remember receivers are global across all open patches)