close #28
This commit is contained in:
parent
2015f97849
commit
78023946cd
30 changed files with 320 additions and 67 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -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
|
||||
|
|
|
@ -58,8 +58,11 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\Editor\AppBuilder.cs" />
|
||||
<Compile Include="Assets\Editor\PdBackendEditor.cs" />
|
||||
<Compile Include="Assets\Editor\PreviewExampleInspector.cs" />
|
||||
<Compile Include="Assets\Editor\EditorToggle.cs" />
|
||||
<Compile Include="Assets\Editor\PdBindEditor.cs" />
|
||||
<Compile Include="Assets\Editor\PdConsole.cs" />
|
||||
<Compile Include="Assets\Editor\TogglePresenter.cs" />
|
||||
<Compile Include="Assets\Editor\UnitTest\UnitTest_ParameterResponder.cs" />
|
||||
<Compile Include="Assets\Scripts\VideoInput\Editor\UnitTest\ComponentFactoryTestCase.cs" />
|
||||
<Compile Include="Assets\Scripts\VideoInput\Editor\UnitTest\KinectSensorTestCase.cs" />
|
||||
<Compile Include="Assets\ThridParty\Editor\KinectCopyPluginDataHelper.cs" />
|
||||
|
|
|
@ -57,11 +57,13 @@
|
|||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\PdBackend\PdBackend.cs" />
|
||||
<Compile Include="Assets\PdBackend\PreviewExample.cs" />
|
||||
<Compile Include="Assets\Scenes\Examples\Example1\script\BallMapping.cs" />
|
||||
<Compile Include="Assets\Scenes\Examples\Example1\script\RmsAnalyzer.cs" />
|
||||
<Compile Include="Assets\Scripts\DataModel\Parameter.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdArray.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdBackend.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdBind.cs" />
|
||||
<Compile Include="Assets\Scripts\PdConnection\PdProcess.cs" />
|
||||
<Compile Include="Assets\Scripts\Versioning\VersionToggleBehaviour.cs" />
|
||||
<Compile Include="Assets\Scripts\VideoInput\ComponentFactory.cs" />
|
||||
<Compile Include="Assets\Scripts\VideoInput\InfraredCamera.cs" />
|
||||
|
|
30
UnityProject/Assets/Editor/EditorToggle.cs
Normal file
30
UnityProject/Assets/Editor/EditorToggle.cs
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3
UnityProject/Assets/Editor/EditorToggle.cs.meta
Normal file
3
UnityProject/Assets/Editor/EditorToggle.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c627fe9ba84425a92fe457030f5f874
|
||||
timeCreated: 1569673031
|
|
@ -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_;
|
36
UnityProject/Assets/Editor/PdConsole.cs
Normal file
36
UnityProject/Assets/Editor/PdConsole.cs
Normal file
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f64c3bbc6cc3ba419c8c56c02e08ec2
|
||||
guid: 48196f9158f8594488b69520ab352d53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
36
UnityProject/Assets/Editor/TogglePresenter.cs
Normal file
36
UnityProject/Assets/Editor/TogglePresenter.cs
Normal file
|
@ -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_;
|
||||
}
|
||||
}
|
||||
}
|
3
UnityProject/Assets/Editor/TogglePresenter.cs.meta
Normal file
3
UnityProject/Assets/Editor/TogglePresenter.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a612dbdf74c948728e59ddede1c1f6d9
|
||||
timeCreated: 1569673646
|
3
UnityProject/Assets/Editor/UnitTest.meta
Normal file
3
UnityProject/Assets/Editor/UnitTest.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a29e3d7fadb042e09992f4e2df21181d
|
||||
timeCreated: 1569682888
|
|
@ -0,0 +1,35 @@
|
|||
using NUnit.Framework;
|
||||
|
||||
namespace cylvester
|
||||
{
|
||||
public class UnitTest_ParameterResponder
|
||||
{
|
||||
[Test]
|
||||
public void Set_Get()
|
||||
{
|
||||
var responder = new Parameter<float>(1.0f);
|
||||
responder.Value = 3.2f;
|
||||
|
||||
Assert.AreEqual(3.2f, responder.Value);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ValueChanged()
|
||||
{
|
||||
var responder = new Parameter<float>(1.0f);
|
||||
responder.Value = 0f;
|
||||
|
||||
void OnValueChanged()
|
||||
{
|
||||
Assert.AreEqual(3.2f, responder.Value);
|
||||
}
|
||||
|
||||
responder.ValueChanged += OnValueChanged;
|
||||
|
||||
responder.Value = 3.2f;
|
||||
|
||||
responder.ValueChanged -= OnValueChanged;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bb461211f174fdc956fa904e780aa12
|
||||
timeCreated: 1569682903
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class PreviewExample : MonoBehaviour
|
||||
{
|
||||
}
|
|
@ -225,6 +225,7 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
mainPatch: test.pd
|
||||
inchannels: 2
|
||||
pdProcess: 0
|
||||
--- !u!4 &987772534
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
8
UnityProject/Assets/Scripts/DataModel.meta
Normal file
8
UnityProject/Assets/Scripts/DataModel.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a845f6e8a2e4efd49b60d8ba5967e05b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
37
UnityProject/Assets/Scripts/DataModel/Parameter.cs
Normal file
37
UnityProject/Assets/Scripts/DataModel/Parameter.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
|
||||
namespace cylvester
|
||||
{
|
||||
interface IParameter<T> where T : IComparable<T>
|
||||
{
|
||||
T Value { set; get; }
|
||||
|
||||
event Action ValueChanged;
|
||||
}
|
||||
|
||||
public class Parameter<T> : IParameter<T> where T : IComparable<T>
|
||||
{
|
||||
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 = () => { };
|
||||
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 006fa2bbb30564c4da3895276ec8a526
|
||||
guid: aeda2217423376843a1f77eedf34b248
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.IO.MemoryMappedFiles;
|
||||
|
||||
namespace PdConnection
|
||||
namespace cylvester
|
||||
{
|
||||
public class PdArray : IDisposable
|
||||
{
|
||||
|
|
34
UnityProject/Assets/Scripts/PdConnection/PdBackend.cs
Normal file
34
UnityProject/Assets/Scripts/PdConnection/PdBackend.cs
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
12
UnityProject/Assets/Scripts/PdConnection/PdBind.cs
Normal file
12
UnityProject/Assets/Scripts/PdConnection/PdBind.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace cylvester
|
||||
{
|
||||
public class PdBind : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
3
UnityProject/Assets/Scripts/PdConnection/PdBind.cs.meta
Normal file
3
UnityProject/Assets/Scripts/PdConnection/PdBind.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54ab37d032df403e881d6a7a78141815
|
||||
timeCreated: 1569681770
|
51
UnityProject/Assets/Scripts/PdConnection/PdProcess.cs
Normal file
51
UnityProject/Assets/Scripts/PdConnection/PdProcess.cs
Normal file
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7e3c06f21c04ec68ed9e1551c072f08
|
||||
timeCreated: 1569686346
|
|
@ -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()
|
||||
|
|
2
UnityProject/UnityProject.sln.DotSettings
Normal file
2
UnityProject/UnityProject.sln.DotSettings
Normal file
|
@ -0,0 +1,2 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=cylvester/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
Loading…
Reference in a new issue