diff --git a/.gitattributes b/.gitattributes
index 67f49e9..22e532f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,7 +1,6 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
* text=auto
-
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
@@ -47,4 +46,7 @@
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
+*.wav filter=lfs diff=lfs merge=lfs -text
+*.aif filter=lfs diff=lfs merge=lfs -text
+*.aiff filter=lfs diff=lfs merge=lfs -text
. text !filter !merge !diff
diff --git a/UnityProject/Assembly-CSharp-Editor.csproj b/UnityProject/Assembly-CSharp-Editor.csproj
index eebedab..c014631 100644
--- a/UnityProject/Assembly-CSharp-Editor.csproj
+++ b/UnityProject/Assembly-CSharp-Editor.csproj
@@ -58,8 +58,11 @@
-
-
+
+
+
+
+
diff --git a/UnityProject/Assembly-CSharp.csproj b/UnityProject/Assembly-CSharp.csproj
index b712f8e..2a7c8af 100644
--- a/UnityProject/Assembly-CSharp.csproj
+++ b/UnityProject/Assembly-CSharp.csproj
@@ -57,11 +57,13 @@
-
-
+
+
+
+
diff --git a/UnityProject/Assets/Editor/EditorToggle.cs b/UnityProject/Assets/Editor/EditorToggle.cs
new file mode 100644
index 0000000..790fc8c
--- /dev/null
+++ b/UnityProject/Assets/Editor/EditorToggle.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace cylvester
+{
+ public interface IEditorToggle
+ {
+ event Action ToggleStateChanged;
+ bool State { get; set; }
+ }
+
+ public class EditorToggle : IEditorToggle
+ {
+ private bool state_;
+
+ public event Action ToggleStateChanged = () => { };
+
+ public bool State
+ {
+ get => state_;
+ set
+ {
+ if (state_ != value)
+ {
+ state_ = value;
+ ToggleStateChanged.Invoke();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/EditorToggle.cs.meta b/UnityProject/Assets/Editor/EditorToggle.cs.meta
new file mode 100644
index 0000000..b9bacf4
--- /dev/null
+++ b/UnityProject/Assets/Editor/EditorToggle.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 6c627fe9ba84425a92fe457030f5f874
+timeCreated: 1569673031
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/PdBackendEditor.cs b/UnityProject/Assets/Editor/PdBindEditor.cs
similarity index 97%
rename from UnityProject/Assets/Editor/PdBackendEditor.cs
rename to UnityProject/Assets/Editor/PdBindEditor.cs
index 7685b4c..eae664c 100644
--- a/UnityProject/Assets/Editor/PdBackendEditor.cs
+++ b/UnityProject/Assets/Editor/PdBindEditor.cs
@@ -2,12 +2,11 @@
using UnityEditor;
using Random = UnityEngine.Random;
-
namespace cylvester
{
- [CustomEditor(typeof(PdBackend))]
- class PdBackendEditor : Editor
+ [CustomEditor(typeof(PdBind))]
+ class PdBindEditor : UnityEditor.Editor
{
private int selectedSpectrum_;
diff --git a/UnityProject/Assets/Editor/PdBackendEditor.cs.meta b/UnityProject/Assets/Editor/PdBindEditor.cs.meta
similarity index 100%
rename from UnityProject/Assets/Editor/PdBackendEditor.cs.meta
rename to UnityProject/Assets/Editor/PdBindEditor.cs.meta
diff --git a/UnityProject/Assets/Editor/PdConsole.cs b/UnityProject/Assets/Editor/PdConsole.cs
new file mode 100644
index 0000000..76ca64e
--- /dev/null
+++ b/UnityProject/Assets/Editor/PdConsole.cs
@@ -0,0 +1,36 @@
+using UnityEditor;
+using UnityEngine;
+
+namespace cylvester
+{
+ public class PdConsole : EditorWindow
+ {
+ private IEditorToggle dspToggle_;
+ private ITogglePresenter togglePresenter_;
+ private IPdBackend pdBackend_;
+
+ [MenuItem("SoundVision/Pd console %#p")]
+ static void Init()
+ {
+ var window = (PdConsole)GetWindow(typeof(PdConsole));
+ window.Show();
+ }
+
+ private void OnEnable()
+ {
+ object[] foundObjects = FindObjectsOfType(typeof(PdBackend));
+
+
+ dspToggle_ = new EditorToggle();
+ togglePresenter_ = new TogglePresenter(dspToggle_, pdBackend_);
+ }
+
+ void OnGUI ()
+ {
+ foundObjects.
+ dspToggle_.State = EditorGUILayout.Toggle("Pure Data Process", dspToggle_.State);
+
+ }
+ }
+
+}
diff --git a/UnityProject/Assets/PdBackend/PreviewExample.cs.meta b/UnityProject/Assets/Editor/PdConsole.cs.meta
similarity index 83%
rename from UnityProject/Assets/PdBackend/PreviewExample.cs.meta
rename to UnityProject/Assets/Editor/PdConsole.cs.meta
index 4c6016e..7bea48d 100644
--- a/UnityProject/Assets/PdBackend/PreviewExample.cs.meta
+++ b/UnityProject/Assets/Editor/PdConsole.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 1f64c3bbc6cc3ba419c8c56c02e08ec2
+guid: 48196f9158f8594488b69520ab352d53
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/UnityProject/Assets/Editor/PreviewExampleInspector.cs b/UnityProject/Assets/Editor/PreviewExampleInspector.cs
deleted file mode 100644
index 7563a1c..0000000
--- a/UnityProject/Assets/Editor/PreviewExampleInspector.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using UnityEngine;
-using UnityEditor;
-[CustomEditor(typeof(PreviewExample))]
-public class PreviewExampleInspector : Editor {
-
- public override bool HasPreviewGUI() { return true; }
-
- public override GUIContent GetPreviewTitle() { return new GUIContent("name"); }
- public override void OnPreviewGUI(Rect r, GUIStyle background) {
- GUI.Box(new Rect(10, 10, 100, 100), "Preview");
- }
-
-}
diff --git a/UnityProject/Assets/Editor/TogglePresenter.cs b/UnityProject/Assets/Editor/TogglePresenter.cs
new file mode 100644
index 0000000..eba08df
--- /dev/null
+++ b/UnityProject/Assets/Editor/TogglePresenter.cs
@@ -0,0 +1,36 @@
+using System;
+
+namespace cylvester
+{
+ public interface ITogglePresenter
+ {
+ }
+
+ public class TogglePresenter : ITogglePresenter, IDisposable
+ {
+ private readonly IEditorToggle editorToggle_;
+ private IPdBackend pdBackend_;
+
+ private readonly Action onToggleChanged_;
+
+ public TogglePresenter(IEditorToggle toggle, IPdBackend pdBackend)
+ {
+ editorToggle_ = toggle;
+ pdBackend_ = pdBackend;
+
+ onToggleChanged_ = () =>
+ {
+ var state = editorToggle_.State;
+ // apply state to pd backend;
+ };
+
+ editorToggle_.ToggleStateChanged += onToggleChanged_;
+
+ }
+
+ public void Dispose()
+ {
+ editorToggle_.ToggleStateChanged -= onToggleChanged_;
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/TogglePresenter.cs.meta b/UnityProject/Assets/Editor/TogglePresenter.cs.meta
new file mode 100644
index 0000000..d756c1a
--- /dev/null
+++ b/UnityProject/Assets/Editor/TogglePresenter.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a612dbdf74c948728e59ddede1c1f6d9
+timeCreated: 1569673646
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/UnitTest.meta b/UnityProject/Assets/Editor/UnitTest.meta
new file mode 100644
index 0000000..a778404
--- /dev/null
+++ b/UnityProject/Assets/Editor/UnitTest.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a29e3d7fadb042e09992f4e2df21181d
+timeCreated: 1569682888
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs b/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs
new file mode 100644
index 0000000..65848b5
--- /dev/null
+++ b/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs
@@ -0,0 +1,35 @@
+using NUnit.Framework;
+
+namespace cylvester
+{
+ public class UnitTest_ParameterResponder
+ {
+ [Test]
+ public void Set_Get()
+ {
+ var responder = new Parameter(1.0f);
+ responder.Value = 3.2f;
+
+ Assert.AreEqual(3.2f, responder.Value);
+ }
+
+ [Test]
+ public void ValueChanged()
+ {
+ var responder = new Parameter(1.0f);
+ responder.Value = 0f;
+
+ void OnValueChanged()
+ {
+ Assert.AreEqual(3.2f, responder.Value);
+ }
+
+ responder.ValueChanged += OnValueChanged;
+
+ responder.Value = 3.2f;
+
+ responder.ValueChanged -= OnValueChanged;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs.meta b/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs.meta
new file mode 100644
index 0000000..184e151
--- /dev/null
+++ b/UnityProject/Assets/Editor/UnitTest/UnitTest_ParameterResponder.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 7bb461211f174fdc956fa904e780aa12
+timeCreated: 1569682903
\ No newline at end of file
diff --git a/UnityProject/Assets/PdBackend/PdBackend.cs b/UnityProject/Assets/PdBackend/PdBackend.cs
deleted file mode 100644
index 3196d09..0000000
--- a/UnityProject/Assets/PdBackend/PdBackend.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Diagnostics;
-using UnityEngine;
-
-namespace cylvester
-{
- public class PdBackend : MonoBehaviour
- {
- [SerializeField] string mainPatch;
- [SerializeField] int inchannels = 2;
-
- private Process pdProcess_;
-
- void Start()
- {
- pdProcess_ = new Process();
- pdProcess_.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
- pdProcess_.StartInfo.UseShellExecute = true;
- pdProcess_.StartInfo.FileName = Application.streamingAssetsPath + "/pd/win/pd.com";
-
- var path = Application.streamingAssetsPath + "/pd/patch/" + mainPatch;
- pdProcess_.StartInfo.Arguments = "-nogui -rt -inchannels " + inchannels + " " + path;
- pdProcess_.Start();
-
-
- }
-
- private void OnDestroy()
- {
- pdProcess_.Kill();
- }
-
-
- }
-
-}
\ No newline at end of file
diff --git a/UnityProject/Assets/PdBackend/PreviewExample.cs b/UnityProject/Assets/PdBackend/PreviewExample.cs
deleted file mode 100644
index 3120dff..0000000
--- a/UnityProject/Assets/PdBackend/PreviewExample.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-using UnityEngine;
-
-public class PreviewExample : MonoBehaviour
-{
-}
diff --git a/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity b/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity
index a59986b..4c3a3a7 100644
--- a/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity
+++ b/UnityProject/Assets/Scenes/Examples/PdBackendDemo/PdBackendDemo.unity
@@ -225,6 +225,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
mainPatch: test.pd
inchannels: 2
+ pdProcess: 0
--- !u!4 &987772534
Transform:
m_ObjectHideFlags: 0
diff --git a/UnityProject/Assets/Scripts/DataModel.meta b/UnityProject/Assets/Scripts/DataModel.meta
new file mode 100644
index 0000000..b7f0726
--- /dev/null
+++ b/UnityProject/Assets/Scripts/DataModel.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: a845f6e8a2e4efd49b60d8ba5967e05b
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/UnityProject/Assets/Scripts/DataModel/Parameter.cs b/UnityProject/Assets/Scripts/DataModel/Parameter.cs
new file mode 100644
index 0000000..6c1e0dc
--- /dev/null
+++ b/UnityProject/Assets/Scripts/DataModel/Parameter.cs
@@ -0,0 +1,37 @@
+using System;
+
+namespace cylvester
+{
+ interface IParameter where T : IComparable
+ {
+ T Value { set; get; }
+
+ event Action ValueChanged;
+ }
+
+ public class Parameter : IParameter where T : IComparable
+ {
+ public Parameter(T initial)
+ {
+ Value = initial;
+ }
+
+ private T value_;
+
+ public T Value
+ {
+ get => value_;
+ set
+ {
+ if (value.CompareTo(value_) == 0)
+ return;
+
+ value_ = value;
+ ValueChanged.Invoke();
+ }
+ }
+
+ public event Action ValueChanged = () => { };
+
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Editor/PreviewExampleInspector.cs.meta b/UnityProject/Assets/Scripts/DataModel/Parameter.cs.meta
similarity index 83%
rename from UnityProject/Assets/Editor/PreviewExampleInspector.cs.meta
rename to UnityProject/Assets/Scripts/DataModel/Parameter.cs.meta
index 48e3813..ed5eca7 100644
--- a/UnityProject/Assets/Editor/PreviewExampleInspector.cs.meta
+++ b/UnityProject/Assets/Scripts/DataModel/Parameter.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 006fa2bbb30564c4da3895276ec8a526
+guid: aeda2217423376843a1f77eedf34b248
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdArray.cs b/UnityProject/Assets/Scripts/PdConnection/PdArray.cs
index c94dc73..5511a98 100644
--- a/UnityProject/Assets/Scripts/PdConnection/PdArray.cs
+++ b/UnityProject/Assets/Scripts/PdConnection/PdArray.cs
@@ -1,7 +1,7 @@
using System;
using System.IO.MemoryMappedFiles;
-namespace PdConnection
+namespace cylvester
{
public class PdArray : IDisposable
{
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdBackend.cs b/UnityProject/Assets/Scripts/PdConnection/PdBackend.cs
new file mode 100644
index 0000000..046a82a
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/PdBackend.cs
@@ -0,0 +1,34 @@
+using System;
+using UnityEngine;
+
+namespace cylvester
+{
+ public interface IPdBackend
+ {
+ bool State { set; }
+ }
+
+ [ExecuteInEditMode]
+ public class PdBackend : MonoBehaviour, IPdBackend
+ {
+ [SerializeField] string mainPatch;
+ [SerializeField] int inchannels = 2;
+
+ private Action onToggled_;
+
+ private void OnEnable()
+ {
+ PdProcess.Instance.Start(mainPatch, inchannels);
+ }
+
+ private void OnDisable()
+ {
+ PdProcess.Instance.Stop();
+ }
+
+ public bool State
+ {
+ set => enabled = value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/PdBackend/PdBackend.cs.meta b/UnityProject/Assets/Scripts/PdConnection/PdBackend.cs.meta
similarity index 100%
rename from UnityProject/Assets/PdBackend/PdBackend.cs.meta
rename to UnityProject/Assets/Scripts/PdConnection/PdBackend.cs.meta
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdBind.cs b/UnityProject/Assets/Scripts/PdConnection/PdBind.cs
new file mode 100644
index 0000000..54d337c
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/PdBind.cs
@@ -0,0 +1,12 @@
+using UnityEngine;
+
+namespace cylvester
+{
+ public class PdBind : MonoBehaviour
+ {
+ private void Start()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdBind.cs.meta b/UnityProject/Assets/Scripts/PdConnection/PdBind.cs.meta
new file mode 100644
index 0000000..bef3afb
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/PdBind.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 54ab37d032df403e881d6a7a78141815
+timeCreated: 1569681770
\ No newline at end of file
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs b/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs
new file mode 100644
index 0000000..8cd322f
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs
@@ -0,0 +1,51 @@
+using System.Diagnostics;
+using UnityEngine;
+using Debug = UnityEngine.Debug;
+
+namespace cylvester
+{
+ interface IPdProcess
+ {
+ void Start(string mainPatch, int numInputChannels);
+ void Stop();
+ }
+
+ public class PdProcess : IPdProcess
+ {
+ private static PdProcess instance_ = null;
+ private Process pdProcess_;
+
+ private PdProcess() // cannot be instantiate normally
+ {
+ }
+
+ public static PdProcess Instance
+ {
+ get { return instance_ ?? (instance_ = new PdProcess()); }
+ }
+
+ public void Start(string mainPatch, int numInputChannels)
+ {
+ if (pdProcess_ != null)
+ return;
+
+ pdProcess_ = new Process();
+ pdProcess_.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+ pdProcess_.StartInfo.UseShellExecute = true;
+ pdProcess_.StartInfo.FileName = Application.streamingAssetsPath + "/pd/win/pd.com";
+
+ var path = Application.streamingAssetsPath + "/pd/patch/" + mainPatch;
+ pdProcess_.StartInfo.Arguments = "-nogui -rt -inchannels " + numInputChannels + " " + path;
+ pdProcess_.Start();
+ Debug.Log("Pd Process started");
+
+ }
+
+ public void Stop()
+ {
+ pdProcess_?.Kill();
+ pdProcess_ = null;
+ Debug.Log("Pd Process stopped");
+ }
+ }
+}
\ No newline at end of file
diff --git a/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs.meta b/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs.meta
new file mode 100644
index 0000000..ad237ec
--- /dev/null
+++ b/UnityProject/Assets/Scripts/PdConnection/PdProcess.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: c7e3c06f21c04ec68ed9e1551c072f08
+timeCreated: 1569686346
\ No newline at end of file
diff --git a/UnityProject/Assets/Scripts/Visualizer/WaveformVisualizerBehaviour.cs b/UnityProject/Assets/Scripts/Visualizer/WaveformVisualizerBehaviour.cs
index 5ace562..f588731 100644
--- a/UnityProject/Assets/Scripts/Visualizer/WaveformVisualizerBehaviour.cs
+++ b/UnityProject/Assets/Scripts/Visualizer/WaveformVisualizerBehaviour.cs
@@ -1,6 +1,6 @@
using UnityEngine;
-namespace Visualizer
+namespace cylvester
{
public class WaveformVisualizerBehaviour : MonoBehaviour
{
@@ -11,11 +11,11 @@ namespace Visualizer
[SerializeField, Range(0f, 10f)] private float scale = 1f;
#pragma warning restore 649
- private PdConnection.PdArray pdArray_;
+ private PdArray pdArray_;
void Start()
{
- pdArray_ = new PdConnection.PdArray(pdArrayName, pdArraySize);
+ pdArray_ = new PdArray(pdArrayName, pdArraySize);
}
void Update()
diff --git a/UnityProject/UnityProject.sln.DotSettings b/UnityProject/UnityProject.sln.DotSettings
new file mode 100644
index 0000000..8e80fbe
--- /dev/null
+++ b/UnityProject/UnityProject.sln.DotSettings
@@ -0,0 +1,2 @@
+
+ True
\ No newline at end of file