add thresholding

This commit is contained in:
Chikashi Miyama 2019-10-07 18:53:36 +02:00
parent f645fbbfc9
commit 25ac95531a
13 changed files with 474 additions and 49 deletions

View file

@ -86,6 +86,7 @@
<Compile Include="Assets\Scripts\Visualizer\IRPanelBehaviour.cs" />
<Compile Include="Assets\Scripts\Visualizer\PointCloudBehaviour.cs" />
<Compile Include="Assets\Scripts\Visualizer\SpectrumVisualizer.cs" />
<Compile Include="Assets\Scripts\Visualizer\Threshold.cs" />
<Compile Include="Assets\Scripts\Visualizer\WaterfallVisualizer.cs" />
<Compile Include="Assets\Scripts\Visualizer\WaveformVisualizerBehaviour.cs" />
<Compile Include="Assets\ThridParty\KinectScript\CameraIntrinsics.cs" />

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7c4a2bd917c527645ab41610b6385dfa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,296 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &684460085
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 684460088}
- component: {fileID: 684460087}
- component: {fileID: 684460086}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &684460086
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 684460085}
m_Enabled: 1
--- !u!20 &684460087
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 684460085}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &684460088
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 684460085}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1718844856
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1718844858}
- component: {fileID: 1718844857}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1718844857
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1718844856}
m_Enabled: 1
serializedVersion: 9
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1718844858
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1718844856}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ebd2f1f277e6d674db0ccce34f5fef00
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 636a92cddddfc2c4abe8de1de62e6d4c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
using UnityEngine;
using UnityEngine.Events;
namespace cylvester
{
public class Threshold : MonoBehaviour
{
[SerializeField] private float threshold;
[SerializeField] private UnityEvent thresholdExceeded;
private bool over_;
public void OnValueReceived(float value)
{
if (value > threshold && !over_)
{
over_ = true;
thresholdExceeded.Invoke();
}
if (value < threshold && over_)
over_ = false;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 35e7f92fa0694ae4add9e3443bd2f860
timeCreated: 1570466622

View file

@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace cylvester
{
public interface IPdBackend
{
IPdArray LevelArray { get; }
IPdArrayContainer SpectrumArrayContainer{ get; }
IPdArrayContainer WaveformArrayContainer{ get; }
}
@ -22,10 +25,11 @@ namespace cylvester
private IMidiParser midiParser_;
private IDspController dspController_;
public IPdArray LevelArray { get; private set; }
public IPdArrayContainer SpectrumArrayContainer { get; private set; }
private IUpdater spectrumArrayUpdater_;
public IPdArrayContainer WaveformArrayContainer { get; private set; }
private IUpdater waveformArrayUpdater_;
private List<IUpdater> updaters_;
private Action onSamplePlaybackChanged_;
private Action<ControlMessage> onControlMessageReceived_;
@ -34,9 +38,10 @@ namespace cylvester
{
SpectrumArrayContainer = new PdArrayContainer("fft_");
WaveformArrayContainer = new PdArrayContainer("wave_");
LevelArray = new PdArray("level", PdConstant.NumMaxInputChannels);
spectrumArrayUpdater_ = (IUpdater) SpectrumArrayContainer;
waveformArrayUpdater_ = (IUpdater) WaveformArrayContainer;
updaters_ = new List<IUpdater>
{(IUpdater) LevelArray, (IUpdater) SpectrumArrayContainer, (IUpdater) WaveformArrayContainer};
pdSender_ = new PdSender(PdConstant.ip, PdConstant.sendPort);
pdReceiver_ = new PdReceiver(PdConstant.receivedPort);
@ -46,15 +51,10 @@ namespace cylvester
samplePlaybackObserver_ = new ChangeObserver<int>(samplePlayback);
onSamplePlaybackChanged_ = () =>
{
pdSender_.Send(new[]{(byte)PdMessage.SampleSound, (byte)samplePlayback});
};
onSamplePlaybackChanged_ = () => { pdSender_.Send(new[]{(byte)PdMessage.SampleSound, (byte)samplePlayback}); };
onControlMessageReceived_ = (message) =>
{
onControlMessageReceived.Invoke(message);
};
onControlMessageReceived_ = (message) => {
onControlMessageReceived.Invoke(message); };
samplePlaybackObserver_.ValueChanged += onSamplePlaybackChanged_;
midiParser_.ControlMessageReceived += onControlMessageReceived_;
@ -73,8 +73,9 @@ namespace cylvester
public void Update()
{
pdReceiver_.Update();
spectrumArrayUpdater_.Update();
waveformArrayUpdater_.Update();
foreach (var updater in updaters_)
updater.Update();
samplePlaybackObserver_.Value = samplePlayback;
}
}

View file

@ -0,0 +1,31 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace cylvester
{
[System.Serializable]
public class LevelEvent : UnityEvent<float>
{
}
public class PdLevelBind : MonoBehaviour
{
[SerializeField] private PdBackend pdbackend;
[SerializeField, Range(1, 16)] private int channel = 1;
[SerializeField] private LevelEvent onLevelChanged;
private float level_;
void Update()
{
var level = pdbackend.LevelArray.Data[channel - 1];
if (level_ != level)
{
level_ = level;
onLevelChanged.Invoke(level_);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1a556319a642d143b7dbcdbace71ad9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,13 +1,13 @@
#N canvas 412 304 670 468 10;
#X obj 217 251 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
#X obj 49 386 dac~, f 6;
#X obj 125 345 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
#X obj 55 386 dac~, f 6;
#N canvas 215 619 730 390 analyzers_______________________________
0;
#X obj 95 44 inlet~;
#X obj 119 69 inlet~;
#X obj 148 96 inlet~;
#X obj 172 121 inlet~;
#X obj 193 47 inlet~;
#X obj 198 45 inlet~;
#X obj 217 72 inlet~;
#X obj 246 101 inlet~;
#X obj 270 124 inlet~;
@ -51,12 +51,12 @@
#X connect 13 0 29 0;
#X connect 14 0 30 0;
#X connect 15 0 31 0;
#X restore 218 298 pd analyzers_______________________________;
#X restore 126 385 pd analyzers_______________________________;
#X obj 46 26 bang~;
#X obj 46 49 count 16;
#X obj 46 76 sel 0;
#X obj 46 102 s shmemupdate;
#N canvas 763 290 686 441 window 0;
#N canvas 763 290 408 235 window 0;
#N canvas 0 0 450 300 (subpatch) 0;
#X array hann 1024 float 1;
#A 0 0 1.88351e-005 3.76403e-005 9.41157e-005 0.000150591 0.000244677
@ -194,35 +194,35 @@
0.000244498 0.000150442 9.39965e-005 3.75807e-005 1.87755e-005;
#X coords 0 1 1023 0 300 100 1 0 0;
#X restore 39 32 graph;
#X restore 420 50 pd window;
#N canvas 2182 728 450 338 commands_from_unity 0;
#X obj 44 31 inlet;
#X obj 108 130 s sample_playback;
#X text 128 55 1 ... sample playback;
#X text 127 38 0 ... dsp start/stop;
#X obj 47 94 route 0 1;
#X msg 3 198 \; pd dsp \$1;
#X obj 86 195 sel 1;
#X obj 89 234 outlet;
#X restore 533 23 pd window;
#N canvas 2182 728 332 292 commands_from_unity 0;
#X obj 66 31 inlet;
#X obj 130 130 s sample_playback;
#X text 150 55 1 ... sample playback;
#X text 149 38 0 ... dsp start/stop;
#X obj 69 94 route 0 1;
#X msg 25 198 \; pd dsp \$1;
#X obj 108 195 sel 1;
#X obj 111 234 outlet;
#X connect 0 0 4 0;
#X connect 4 0 5 0;
#X connect 4 0 6 0;
#X connect 4 1 1 0;
#X connect 6 0 7 0;
#X restore 230 79 pd commands_from_unity;
#N canvas 667 603 877 437 sample_playback 0;
#X restore 231 60 pd commands_from_unity;
#N canvas 667 603 480 371 sample_playback 0;
#X obj 86 166 readsf~;
#X obj 95 6 r sample_playback;
#X obj 87 280 outlet~;
#X obj 269 241 makefilename ../../../../AudioSamples/%s;
#X obj 269 280 route symbol;
#X obj 269 202 symbol;
#X obj 269 163 text get samplefiles;
#X floatatom 269 125 5 0 0 0 - - -;
#X obj 168 221 makefilename ../../../../AudioSamples/%s;
#X obj 168 260 route symbol;
#X obj 168 182 symbol;
#X obj 168 143 text get samplefiles;
#X floatatom 168 105 5 0 0 0 - - -;
#X obj 95 38 sel 0;
#X obj 122 72 - 1;
#X msg 33 114 0;
#X msg 269 318 open \$1 \, 1;
#X msg 168 298 open \$1 \, 1;
#X connect 0 0 2 0;
#X connect 1 0 8 0;
#X connect 3 0 4 0;
@ -235,23 +235,29 @@
#X connect 9 0 7 0;
#X connect 10 0 0 0;
#X connect 11 0 0 0;
#X restore 55 301 pd sample_playback;
#X obj 230 24 netreceive -u -b 54345;
#X restore 55 306 pd sample_playback;
#X obj 231 22 netreceive -u -b 54345;
#X obj 45 140 text define -k samplefiles;
#A set Back_Back.wav \; Brutal_Synth.wav \; Dialog.wav \; Drums.wav
\; Fox_Melo.wav \; Kick.wav \; Pads+Strings.wav \; Rose_Sax.wav \;
Roses_Front.wav;
#X obj 236 215 netsend -u -b;
#X msg 231 140 connect localhost 56765;
#X obj 253 110 loadbang;
#X obj 231 245 netsend -u -b;
#X msg 231 144 connect localhost 56765;
#X obj 253 114 loadbang;
#X obj 86 199 list prepend send;
#X obj 86 223 list trim;
#X obj 86 175 midiin;
#X msg 402 128 23 31;
#X msg 442 132 80 84, f 10;
#X text 414 102 sample CC;
#X msg 392 180 send 176 \$1 \$2;
#X text 416 201 176... control channel 1;
#X msg 410 115 23 31;
#X msg 457 115 80 84, f 10;
#X text 422 89 sample CC;
#X msg 424 161 send 176 \$1 \$2;
#X text 423 183 176... control channel 1;
#N canvas 695 332 450 300 level 0;
#X obj 90 182 table level 16;
#X obj 89 152 shmem level 16;
#X obj 89 127 r shmemupdate;
#X connect 2 0 1 0;
#X restore 532 55 pd level;
#X connect 0 0 2 0;
#X connect 0 1 2 1;
#X connect 0 2 2 2;

View file

@ -1,5 +1,5 @@
#N canvas 1177 364 450 300 10;
#X obj 54 93 inlet~;
#X obj 55 40 inlet~;
#X obj 55 139 spectrum \$1;
#X obj 229 240 table fft_\$1 512;
#X obj 200 177 r shmemupdate;
@ -7,8 +7,16 @@
#X obj 117 241 table wave_\$1 512;
#X obj 119 217 shmem wave_\$1 512;
#X obj 135 125 tabwrite~ wave_\$1;
#X obj 270 143 tabwrite level;
#X obj 375 81 loadbang;
#X obj 375 110 f \$1, f 6;
#X obj 270 111 env~ 1024 2048;
#X connect 0 0 1 0;
#X connect 0 0 7 0;
#X connect 0 0 11 0;
#X connect 3 0 4 0;
#X connect 3 0 6 0;
#X connect 3 0 7 0;
#X connect 9 0 10 0;
#X connect 10 0 8 1;
#X connect 11 0 8 0;