change the format of UDP communication from Unity to Pd to ascii

This commit is contained in:
Chikashi Miyama 2019-10-27 17:28:00 +01:00
parent 1e5d72e80c
commit 768ce1ed0d
13 changed files with 662 additions and 39 deletions

View file

@ -65,6 +65,7 @@
<Compile Include="Assets\Scenes\Examples\MIDI\script\PositionBind.cs" /> <Compile Include="Assets\Scenes\Examples\MIDI\script\PositionBind.cs" />
<Compile Include="Assets\Scenes\Examples\PdBackend\script\BoomBall.cs" /> <Compile Include="Assets\Scenes\Examples\PdBackend\script\BoomBall.cs" />
<Compile Include="Assets\Scenes\Examples\PostProcessing\script\BokehBind.cs" /> <Compile Include="Assets\Scenes\Examples\PostProcessing\script\BokehBind.cs" />
<Compile Include="Assets\Scenes\Examples\TextToPd\script\TextToPd.cs" />
<Compile Include="Assets\Scenes\Examples\Texture\TextureMapper.cs" /> <Compile Include="Assets\Scenes\Examples\Texture\TextureMapper.cs" />
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\FlareBind.cs" /> <Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\FlareBind.cs" />
<Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\SmokeBind.cs" /> <Compile Include="Assets\Scenes\Examples\VisualEffectGraph\script\SmokeBind.cs" />

View file

@ -152,15 +152,15 @@ MonoBehaviour:
pdBackend: {fileID: 987772533} pdBackend: {fileID: 987772533}
selection: selection:
serializedVersion: 2 serializedVersion: 2
x: 16.083769 x: 0
y: 75 y: 36
width: 97.84293 width: 43.544582
height: 128 height: 210
energyChanged: energyChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: m_Calls:
- m_Target: {fileID: 428795648} - m_Target: {fileID: 428795649}
m_MethodName: m_MethodName: OnValueChanged
m_Mode: 0 m_Mode: 0
m_Arguments: m_Arguments:
m_ObjectArgument: {fileID: 0} m_ObjectArgument: {fileID: 0}
@ -594,7 +594,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9de1490c361f2bd48b4a81ad0457a4e7, type: 3} m_Script: {fileID: 11500000, guid: 9de1490c361f2bd48b4a81ad0457a4e7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
threshold: 20 threshold: 500
attackTime: 0.01 attackTime: 0.01
releaseTime: 0.5 releaseTime: 0.5
holdTime: 0.2 holdTime: 0.2

View file

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

View file

@ -0,0 +1,563 @@
%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: 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 &371070832
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 371070835}
- component: {fileID: 371070834}
- component: {fileID: 371070833}
- component: {fileID: 371070836}
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 &371070833
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 371070832}
m_Enabled: 1
--- !u!20 &371070834
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 371070832}
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: 0
m_AllowMSAA: 0
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &371070835
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 371070832}
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!114 &371070836
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 371070832}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 23c1ce4fb46143f46bc5cb5224c934f6, type: 3}
m_Name:
m_EditorClassIdentifier:
clearColorMode: 0
backgroundColorHDR: {r: 0.025, g: 0.07, b: 0.19, a: 0}
clearDepth: 1
volumeLayerMask:
serializedVersion: 2
m_Bits: 1
volumeAnchorOverride: {fileID: 0}
antialiasing: 0
SMAAQuality: 2
dithering: 0
stopNaNs: 0
physicalParameters:
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
flipYMode: 0
fullscreenPassthrough: 0
allowDynamicResolution: 0
customRenderingSettings: 0
invertFaceCulling: 0
probeLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPathCustomFrameSettings:
bitDatas:
data1: 69284264935197
data2: 4539628424389459968
lodBias: 1
lodBiasMode: 0
maximumLODLevel: 0
maximumLODLevelMode: 0
renderingPathCustomFrameSettingsOverrideMask:
mask:
data1: 0
data2: 0
defaultFrameSettings: 0
m_Version: 5
m_ObsoleteRenderingPath: 0
m_ObsoleteFrameSettings:
overrides: 0
enableShadow: 0
enableContactShadows: 0
enableShadowMask: 0
enableSSR: 0
enableSSAO: 0
enableSubsurfaceScattering: 0
enableTransmission: 0
enableAtmosphericScattering: 0
enableVolumetrics: 0
enableReprojectionForVolumetrics: 0
enableLightLayers: 0
enableExposureControl: 1
diffuseGlobalDimmer: 0
specularGlobalDimmer: 0
shaderLitMode: 0
enableDepthPrepassWithDeferredRendering: 0
enableTransparentPrepass: 0
enableMotionVectors: 0
enableObjectMotionVectors: 0
enableDecals: 0
enableRoughRefraction: 0
enableTransparentPostpass: 0
enableDistortion: 0
enablePostprocess: 0
enableOpaqueObjects: 0
enableTransparentObjects: 0
enableRealtimePlanarReflection: 0
enableMSAA: 0
enableAsyncCompute: 0
runLightListAsync: 0
runSSRAsync: 0
runSSAOAsync: 0
runContactShadowsAsync: 0
runVolumeVoxelizationAsync: 0
lightLoopSettings:
overrides: 0
enableDeferredTileAndCluster: 0
enableComputeLightEvaluation: 0
enableComputeLightVariants: 0
enableComputeMaterialVariants: 0
enableFptlForForwardOpaque: 0
enableBigTilePrepass: 0
isFptlEnabled: 0
--- !u!1 &1669752341
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1669752343}
- component: {fileID: 1669752342}
- component: {fileID: 1669752345}
- component: {fileID: 1669752344}
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 &1669752342
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1669752341}
m_Enabled: 1
serializedVersion: 9
m_Type: 1
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 3.1415927
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: 2
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 &1669752343
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1669752341}
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}
--- !u!114 &1669752344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1669752341}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c6c2871f720b2af4e9210febdac74517, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 1
shadowResolution: 512
shadowDimmer: 1
volumetricShadowDimmer: 1
shadowFadeDistance: 10000
contactShadows: 0
shadowTint: {r: 0, g: 0, b: 0, a: 1}
viewBiasMin: 0.2
viewBiasMax: 100
viewBiasScale: 1
normalBiasMin: 0.5
normalBiasMax: 0.5
normalBiasScale: 1
sampleBiasScale: 0
edgeLeakFixup: 0
edgeToleranceNormal: 1
edgeTolerance: 1
shadowCascadeCount: 4
shadowCascadeRatios:
- 0.05
- 0.2
- 0.3
shadowCascadeBorders:
- 0.2
- 0.2
- 0.2
- 0.2
shadowAlgorithm: 0
shadowVariant: 0
shadowPrecision: 0
--- !u!114 &1669752345
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1669752341}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a68c43fe1f2a47cfa234b5eeaa98012, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
m_Version: 5
directionalIntensity: 3.1415927
punctualIntensity: 600
areaIntensity: 200
enableSpotReflector: 0
luxAtDistance: 1
m_InnerSpotPercent: 0
lightDimmer: 1
m_VolumetricDimmer: 1
lightUnit: 2
fadeDistance: 10000
affectDiffuse: 1
affectSpecular: 1
nonLightmappedOnly: 0
lightTypeExtent: 0
m_SpotLightShape: 0
shapeWidth: 0.5
shapeHeight: 0.5
aspectRatio: 1
shapeRadius: 0
maxSmoothness: 0.99
applyRangeAttenuation: 1
useOldInspector: 0
useVolumetric: 1
featuresFoldout: 1
showAdditionalSettings: 0
displayLightIntensity: 3.1415927
displayAreaLightEmissiveMesh: 0
areaLightCookie: {fileID: 0}
areaLightShadowCone: 120
useScreenSpaceShadows: 0
evsmExponent: 15
evsmLightLeakBias: 0
evsmVarianceBias: 0.00001
evsmBlurPasses: 0
lightLayers: 1
lightlayersMask: 1
linkShadowLayers: 1
shadowNearPlane: 0.1
shadowSoftness: 0.5
blockerSampleCount: 24
filterSampleCount: 16
minFilterSize: 0.00001
kernelSize: 5
lightAngle: 1
maxDepthBias: 0.001
--- !u!1 &1788337932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1788337934}
- component: {fileID: 1788337933}
- component: {fileID: 1788337935}
m_Layer: 0
m_Name: PdBackend
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1788337933
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788337932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3ba69cee3466a304d9d570268f717413, type: 3}
m_Name:
m_EditorClassIdentifier:
midiMessageReceived:
m_PersistentCalls:
m_Calls: []
midiClockReceived:
m_PersistentCalls:
m_Calls: []
samplePlayback: 0
--- !u!4 &1788337934
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788337932}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1788337935
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788337932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: af763e011f6b2f04eaa8391f28e21b56, type: 3}
m_Name:
m_EditorClassIdentifier:
pdBackend: {fileID: 1788337933}

View file

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

View file

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

View file

@ -0,0 +1,12 @@
using cylvester;
using UnityEngine;
public class TextToPd : MonoBehaviour
{
[SerializeField] private PdBackend pdBackend;
void Start()
{
pdBackend.Message("Hello world\n");
}
}

View file

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

View file

@ -1,3 +1,5 @@
using System.Text;
namespace cylvester namespace cylvester
{ {
public interface IDspController public interface IDspController
@ -18,7 +20,7 @@ namespace cylvester
{ {
set set
{ {
sender_.Send (new[]{(byte)PdMessage.Dsp, (byte)(value?1:0)}); sender_.Send ("processing " + (value ? '1' : '0'));
} }
} }
} }

View file

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using UnityEditor.VersionControl;
using UnityEngine; using UnityEngine;
using UnityEngine.Events; using UnityEngine.Events;
@ -11,6 +13,7 @@ namespace cylvester
IPdArray LevelArray { get; } IPdArray LevelArray { get; }
IPdArrayContainer SpectrumArrayContainer{ get; } IPdArrayContainer SpectrumArrayContainer{ get; }
IPdArrayContainer WaveformArrayContainer{ get; } IPdArrayContainer WaveformArrayContainer{ get; }
void Message(string message);
} }
public class PdBackend : MonoBehaviour, IPdBackend public class PdBackend : MonoBehaviour, IPdBackend
@ -18,7 +21,6 @@ namespace cylvester
[SerializeField] UnityMidiEvent midiMessageReceived = null; [SerializeField] UnityMidiEvent midiMessageReceived = null;
[SerializeField] UnityEvent midiClockReceived = null; [SerializeField] UnityEvent midiClockReceived = null;
public int samplePlayback; public int samplePlayback;
private IChangeObserver<int> samplePlaybackObserver_; private IChangeObserver<int> samplePlaybackObserver_;
@ -55,7 +57,10 @@ namespace cylvester
samplePlaybackObserver_ = new ChangeObserver<int>(samplePlayback); samplePlaybackObserver_ = new ChangeObserver<int>(samplePlayback);
onSamplePlaybackChanged_ = () => { pdSender_.Send(new[]{(byte)PdMessage.SampleSound, (byte)samplePlayback}); }; onSamplePlaybackChanged_ = () =>
{
pdSender_.Send("sample " + samplePlayback);
};
onMidiMessageReceived_ = (message) => { midiMessageReceived.Invoke(message); }; onMidiMessageReceived_ = (message) => { midiMessageReceived.Invoke(message); };
onMidiClockReceived_ = () => { midiClockReceived.Invoke(); }; onMidiClockReceived_ = () => { midiClockReceived.Invoke(); };
@ -84,5 +89,11 @@ namespace cylvester
samplePlaybackObserver_.Value = samplePlayback; samplePlaybackObserver_.Value = samplePlayback;
} }
public void Message(string message)
{
pdSender_.Send("message " + message);
}
} }
} }

View file

@ -1,11 +1,5 @@
namespace cylvester namespace cylvester
{ {
enum PdMessage
{
Dsp = 0,
SampleSound = 1
}
public class PdConstant public class PdConstant
{ {
public static readonly int NumMaxInputChannels = 16; public static readonly int NumMaxInputChannels = 16;

View file

@ -1,12 +1,13 @@
using System; using System;
using System.Net; using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text;
namespace cylvester namespace cylvester
{ {
public interface IPdSender : IDisposable public interface IPdSender : IDisposable
{ {
void Send(byte[] bytes); void Send(string str);
} }
public class PdSender : IPdSender public class PdSender : IPdSender
@ -19,9 +20,9 @@ namespace cylvester
socket_.Connect(IPAddress.Parse(ip), port); socket_.Connect(IPAddress.Parse(ip), port);
} }
public void Send(byte[] bytes) public void Send(string str)
{ {
socket_.Send(bytes); socket_.Send(Encoding.ASCII.GetBytes(str + "\n"));
} }
public void Dispose() public void Dispose()

View file

@ -1,4 +1,4 @@
#N canvas 758 125 670 468 10; #N canvas 758 125 1031 487 10;
#X obj 142 343 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; #X obj 142 343 adc~ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16;
#X obj 72 384 dac~, f 6; #X obj 72 384 dac~, f 6;
#N canvas 215 619 730 390 analyzers_______________________________ #N canvas 215 619 730 390 analyzers_______________________________
@ -195,20 +195,25 @@
#X coords 0 1 1023 0 300 100 1 0 0; #X coords 0 1 1023 0 300 100 1 0 0;
#X restore 39 32 graph; #X restore 39 32 graph;
#X restore 550 21 pd window; #X restore 550 21 pd window;
#N canvas 2182 728 332 292 commands_from_unity 0; #N canvas 561 588 332 292 commands_from_unity 1;
#X obj 66 31 inlet; #X obj 66 31 inlet;
#X obj 130 130 s sample_playback; #X obj 155 197 s sample_playback;
#X text 150 55 1 ... sample playback; #X text 150 55 1 ... sample playback;
#X text 149 38 0 ... dsp start/stop; #X text 149 38 0 ... dsp start/stop;
#X obj 69 94 route 0 1;
#X msg 25 198 \; pd dsp \$1; #X msg 25 198 \; pd dsp \$1;
#X obj 108 195 sel 1; #X obj 108 195 sel 1;
#X obj 111 234 outlet; #X obj 111 234 outlet;
#X connect 0 0 4 0; #X text 150 69 2 ... text message;
#X connect 4 0 5 0; #X obj 171 149 print;
#X connect 4 0 6 0; #X obj 27 141 t f;
#X connect 4 1 1 0; #X obj 70 94 route processing sample message;
#X connect 6 0 7 0; #X connect 0 0 10 0;
#X connect 5 0 6 0;
#X connect 9 0 4 0;
#X connect 10 0 5 0;
#X connect 10 0 9 0;
#X connect 10 1 1 0;
#X connect 10 2 8 0;
#X restore 248 58 pd commands_from_unity; #X restore 248 58 pd commands_from_unity;
#N canvas 667 603 480 371 sample_playback 0; #N canvas 667 603 480 371 sample_playback 0;
#X obj 86 166 readsf~; #X obj 86 166 readsf~;
@ -236,7 +241,6 @@
#X connect 10 0 0 0; #X connect 10 0 0 0;
#X connect 11 0 0 0; #X connect 11 0 0 0;
#X restore 72 304 pd sample_playback; #X restore 72 304 pd sample_playback;
#X obj 248 20 netreceive -u -b 54345;
#X obj 62 138 text define -k samplefiles; #X obj 62 138 text define -k samplefiles;
#A set Back_Back.wav \; Brutal_Synth.wav \; Dialog.wav \; Drums.wav #A set Back_Back.wav \; Brutal_Synth.wav \; Dialog.wav \; Drums.wav
\; Fox_Melo.wav \; Kick.wav \; Pads+Strings.wav \; Rose_Sax.wav \; \; Fox_Melo.wav \; Kick.wav \; Pads+Strings.wav \; Rose_Sax.wav \;
@ -259,6 +263,7 @@ Roses_Front.wav;
#X connect 2 0 1 0; #X connect 2 0 1 0;
#X restore 549 53 pd level; #X restore 549 53 pd level;
#X obj 12 173 midirealtimein; #X obj 12 173 midirealtimein;
#X obj 248 20 netreceive -u 54345;
#X connect 0 0 2 0; #X connect 0 0 2 0;
#X connect 0 1 2 1; #X connect 0 1 2 1;
#X connect 0 2 2 2; #X connect 0 2 2 2;
@ -278,17 +283,17 @@ Roses_Front.wav;
#X connect 3 0 4 0; #X connect 3 0 4 0;
#X connect 4 0 5 0; #X connect 4 0 5 0;
#X connect 5 0 6 0; #X connect 5 0 6 0;
#X connect 8 0 13 0; #X connect 8 0 12 0;
#X connect 9 0 1 0; #X connect 9 0 1 0;
#X connect 9 0 1 1; #X connect 9 0 1 1;
#X connect 9 0 2 0; #X connect 9 0 2 0;
#X connect 10 0 8 0; #X connect 12 0 11 0;
#X connect 13 0 12 0; #X connect 13 0 12 0;
#X connect 14 0 13 0; #X connect 14 0 15 0;
#X connect 15 0 16 0; #X connect 15 0 11 0;
#X connect 16 0 12 0; #X connect 16 0 14 0;
#X connect 17 0 15 0; #X connect 17 0 20 0;
#X connect 18 0 21 0; #X connect 18 0 20 0;
#X connect 19 0 21 0; #X connect 20 0 11 0;
#X connect 21 0 12 0; #X connect 23 0 14 0;
#X connect 24 0 15 0; #X connect 24 0 8 0;