diff --git a/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity b/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity index ff51c72..910b961 100644 --- a/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity +++ b/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity @@ -202,13 +202,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 54ab37d032df403e881d6a7a78141815, type: 3} m_Name: m_EditorClassIdentifier: - channel: 0 - rectangularSelection: - serializedVersion: 2 - x: 40.02606 - y: 49 - width: 44.19544 - height: 138 + pdBackend: {fileID: 987772533} --- !u!1 &267275365 GameObject: m_ObjectHideFlags: 0 diff --git a/docs/Pdbackend.md b/docs/Pdbackend.md new file mode 100644 index 0000000..bc81a7c --- /dev/null +++ b/docs/Pdbackend.md @@ -0,0 +1,28 @@ +# How Pd Backend works + +Sound Vision System requires audio input and sound analysis and we want to use Pd for that. However, it is cumbersome to deal with two software in the workflow. Our strategy is to keep Pd patch as simple as possible, and pull as many logical, compositional, and artistic components to Unity world. + +## Pd without GUI + +Pd can be launched without GUI from the command line (in Windows cmd.exe). It means if we can invoke the command from Unity software we can use Pd as a background process. In order to realize this **PdBackend.cs** exists. We need one and only one instance of PdBackend.cs in our scene so that the script starts the Pd process without GUI when the game starts and stops the Pd process when the game ends. + +## Pd Process and DSP + +As soon as Pd process starts, it automatically starts DSP. There is currently no option to stop DSP. + +## Where is Pd binary + +In the Assets/StreamingAssets/pd/win folder. Unity serializes all data outside of StreamingAssets folder but files in this folder remain unarchived after build. + +## Where is the main Pd patch + +The patch stays in Assets/StreamingAssets/pd/patch folder. The name of patch is **analyzer.pd** + +## Communication between Pd and Unity + +via IPC (Inter Process Communication). I made an external Pd object called **shmem.dll** for this. shmem is an abbreviation of shared memory. Shared memory is a special region of RAM allocated by the OS that can be accessed by more than one processes (in our case Pd and Unity). You need to copy the entire data in Array object to shmem by sending bang to shmem object so that Unity can read the content of the designated array. I'm using windows API directly thus no compatibility with Mac. + +## Caution + +Do not open the Pd patch and starts the game at the same time. If you do so, the behaviour is undefined. +