Browse Source

Midi Script Start

post-projects
Cailean Finn 1 year ago
parent
commit
5e1415270e
  1. 8
      Assets/MIDI Controller.meta
  2. 355
      Assets/MIDI Controller/Dwell.inputactions
  3. 0
      Assets/MIDI Controller/Dwell.inputactions.meta
  4. 0
      Assets/MIDI Controller/InputSystem.inputsettings.asset
  5. 0
      Assets/MIDI Controller/InputSystem.inputsettings.asset.meta
  6. 13019
      Assets/Midi-Test.unity
  7. 204
      Assets/Scripts/MidiMap.cs
  8. 11
      Assets/Scripts/MidiMap.cs.meta
  9. 155
      Assets/Timeline/MIDI Timeline.playable
  10. 8
      Assets/Timeline/MIDI Timeline.playable.meta
  11. 16
      ProjectSettings/TimelineSettings.asset

8
Assets/MIDI Controller.meta

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

355
Assets/Dwell.inputactions → Assets/MIDI Controller/Dwell.inputactions

@ -791,6 +791,361 @@
"isPartOfComposite": false "isPartOfComposite": false
} }
] ]
},
{
"name": "MIDI",
"id": "0f9fca80-b0be-4ae0-b2b4-c0fe98322788",
"actions": [
{
"name": "Slider_1",
"type": "Value",
"id": "c58e2e8b-1886-41d0-977d-1346eb550456",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_2",
"type": "Value",
"id": "d0a8521b-25f5-4b9d-bf44-303b8d04bd3d",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_3",
"type": "Value",
"id": "3b6c38dc-46d0-43e0-8d0c-871142fea3d8",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_4",
"type": "Value",
"id": "ef91cd53-93a6-4d5e-a392-50e8ba0843da",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_5",
"type": "Value",
"id": "19c01748-248f-4fab-b177-ddfa1569e71f",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_6",
"type": "Value",
"id": "93f002a2-36f9-4e97-801a-4a4425ecdd47",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_7",
"type": "Value",
"id": "9b0e60a3-0346-4903-81b5-bcad44485510",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
},
{
"name": "Slider_8",
"type": "Value",
"id": "20e3d12e-5b53-4e0b-a0d9-247f97d841de",
"expectedControlType": "MidiValue",
"processors": "",
"interactions": "",
"initialStateCheck": true
}
],
"bindings": [
{
"name": "",
"id": "3a5a1da7-f31e-4404-8023-106af589a7b0",
"path": "<MidiDevice>/control000",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "95ff6365-beae-46a6-8090-037eb42ae310",
"path": "<MidiDevice>/control016",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "50c52b7a-7992-47ba-8250-cdd570c3d10e",
"path": "<MidiDevice>/control032",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "cf52f128-71e7-4793-afb7-37cf72965c08",
"path": "<MidiDevice>/control048",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5ae89f3b-b2e7-475e-9edf-f6f10ba344d9",
"path": "<MidiDevice>/control064",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_1",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "de133fb9-2c8a-4776-8e22-9294a4800730",
"path": "<MidiDevice>/control001",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_2",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "8208496d-f2ec-471a-9518-efa361135718",
"path": "<MidiDevice>/control017",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_2",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "a60f118f-5b91-412c-a52f-2f927ea45a1a",
"path": "<MidiDevice>/control033",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_2",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "34195748-ca29-4506-9857-0b053510e2e9",
"path": "<MidiDevice>/control049",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_2",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "9d4477ed-3348-4837-844a-928d8b19212a",
"path": "<MidiDevice>/control065",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_2",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "5145a846-585e-489b-951a-77f3c6d85c76",
"path": "<MidiDevice>/control002",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_3",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "e3bbcd48-039c-4dac-994d-08ebc5a647c6",
"path": "<MidiDevice>/control018",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_3",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "4d20c00d-4576-4624-98e3-30b91c6b2ade",
"path": "<MidiDevice>/control034",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_3",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "c5d068a0-1350-4c34-8315-25f3dacd9c39",
"path": "<MidiDevice>/control050",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_3",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "78d3035e-d31d-490e-8f66-909bb0c18fa2",
"path": "<MidiDevice>/control066",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_3",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "861abe0d-a237-45fe-8bd2-ac9126d0764a",
"path": "<MidiDevice>/control003",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_4",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "33a3173d-84ba-483d-a913-4ae1b939f2db",
"path": "<MidiDevice>/control019",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_4",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "ac8f0c67-15bb-430f-87af-ba4a9f13547a",
"path": "<MidiDevice>/control004",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_5",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "6fdf0f03-5654-4dba-865f-71651e486fcc",
"path": "<MidiDevice>/control020",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_5",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "ad17a53c-b1be-427a-8f89-bb93fe696710",
"path": "<MidiDevice>/control005",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_6",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "888945fa-2831-4673-a1b2-f87c92cd1036",
"path": "<MidiDevice>/control021",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_6",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "b50d107b-4ad9-4b37-b107-13b44d0804b4",
"path": "<MidiDevice>/control006",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_7",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "cbdbb37d-d72d-405b-8702-666cede25873",
"path": "<MidiDevice>/control022",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_7",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "64fe9f56-6d6b-445c-ae34-ac22b99fee64",
"path": "<MidiDevice>/control007",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_8",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "b0edbfcd-f383-4056-882e-0ba1551ff2d8",
"path": "<MidiDevice>/control023",
"interactions": "",
"processors": "",
"groups": "MIDI",
"action": "Slider_8",
"isComposite": false,
"isPartOfComposite": false
}
]
} }
], ],
"controlSchemes": [ "controlSchemes": [

0
Assets/Dwell.inputactions.meta → Assets/MIDI Controller/Dwell.inputactions.meta

0
Assets/InputSystem.inputsettings.asset → Assets/MIDI Controller/InputSystem.inputsettings.asset

0
Assets/InputSystem.inputsettings.asset.meta → Assets/MIDI Controller/InputSystem.inputsettings.asset.meta

13019
Assets/Midi-Test.unity

File diff suppressed because it is too large

204
Assets/Scripts/MidiMap.cs

@ -0,0 +1,204 @@
using Minis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.VFX;
public class MidiMap : MonoBehaviour
{
public VisualEffect m_VFX;
// Point VFX Parameters
private int m_PLifeMax;
private int m_PRate;
private int m_PNoise;
private int m_PSpeed;
private int m_PRatio;
private int m_PGravity;
private int m_PFreq;
private int m_PTurb;
// Line VFX Parameters
private int m_LToggle;
private int m_LRate;
private int m_LLifetime;
private int m_LRange;
private int m_LThickness;
// Bubble VFX Parameters
private int m_BSize;
private int m_BRate;
private int m_BLifetime;
private int m_BTurb;
private int m_BFreq;
private int m_BForce;
private int m_BToggle;
float f_PLifeMax = 0f;
float f_PRate = 0f;
float f_PNoise = 0f;
float f_PSpeed = 0f;
float f_PRatio = 0f;
float f_PGravity = 0f;
float f_PFreq = 0f;
float f_PTurb = 0f;
float f_LRate = 0f;
float f_LLifetime = 0f;
bool f_LToggle = false;
float f_LRange = 0f;
float f_LThickness = 0f;
float f_BSize = 0f;
float f_BRate = 0f;
float f_BFreq = 0f;
float f_BLifetime = 0f;
float f_BTurb = 0f;
bool f_BToggle = false;
float f_BForceX = 0f;
float f_BForceY = 0f;
float f_BForceZ = 0f;
float testMIDI = 0f;
float testMIDInoise = 0f;
float m_Slider = 0f;
bool m_BSlider = false;
float m_Potent = 0f;
float[] m_SliderIn = new float[8];
float[] m_PotIn = new float[8];
void Start()
{
m_PLifeMax = Shader.PropertyToID("Point Lifetime Max");
m_PRate = Shader.PropertyToID("Point Rate");
m_PRatio = Shader.PropertyToID("Turbulences Ratio");
m_PNoise = Shader.PropertyToID("Noise");
m_PSpeed = Shader.PropertyToID("Turbulences Speed");
m_PFreq = Shader.PropertyToID("Turbulences Frequency");
m_PGravity = Shader.PropertyToID("Gravity Point");
m_PTurb = Shader.PropertyToID("Turbulences");
m_LToggle = Shader.PropertyToID("Toggle Line");
m_LRate = Shader.PropertyToID("Line Rate");
m_LLifetime = Shader.PropertyToID("Line Lifetime");
m_LRange = Shader.PropertyToID("Line Range");
m_LThickness = Shader.PropertyToID("Line Thickness");
m_BFreq = Shader.PropertyToID("Bubble Turbulences Frequency");
m_BRate = Shader.PropertyToID("Bubble Rate");
m_BLifetime = Shader.PropertyToID("Bubble Lifetime");
m_BTurb = Shader.PropertyToID("Bubble Turbulences");
m_BForce = Shader.PropertyToID("Bubble Force");
m_BToggle = Shader.PropertyToID("Toggle Bubble");
m_BSize = Shader.PropertyToID("Bubble Size");
InputSystem.onDeviceChange += (device, change) =>
{
if (change != InputDeviceChange.Added) {
return;
}
var midiDevice = device as Minis.MidiDevice;
if (midiDevice == null)
{
return; }
midiDevice.onWillControlChange += (device, change) =>
{
if(device.controlNumber == 61)
{
if (m_BSlider)
{
m_BSlider = false;
return;
}
// Left
m_Slider -= 1;
if(m_Slider < 0) { m_Slider = 2; }
m_BSlider = true;
}
if (device.controlNumber == 62)
{
// Right
if (m_BSlider)
{
m_BSlider = false;
return;
}
m_Slider += 1;
if (m_Slider > 2) { m_Slider = 0; }
m_BSlider = true;
}
if(device.controlNumber < 8)
{
m_SliderIn[device.controlNumber] = (float)change;
}
if (device.controlNumber >= 16 && device.controlNumber <=23)
{
m_PotIn[device.controlNumber - 16] = (float)change;
}
};
};
}
void Update()
{
foreach (var item in m_PotIn)
{
Debug.Log(item);
}
SetupVFX();
}
void SetupVFX()
{
var eventAttribute = m_VFX.CreateVFXEventAttribute();
m_VFX.SetFloat(m_PRate, f_PRate);
m_VFX.SetFloat(m_PLifeMax, f_PLifeMax);
m_VFX.SetFloat(m_PNoise, f_PNoise);
m_VFX.SetFloat(m_PTurb, f_PTurb);
m_VFX.SetFloat(m_PSpeed, f_PSpeed);
m_VFX.SetFloat(m_LRate, f_LRate);
m_VFX.SetFloat(m_LLifetime, f_LLifetime);
m_VFX.SetBool(m_LToggle, f_LToggle);
m_VFX.SetFloat(m_LRange, f_LRange);
m_VFX.SetFloat(m_LThickness, f_LThickness);
m_VFX.SetFloat(m_BSize, f_BSize);
m_VFX.SetFloat(m_BRate, f_BRate);
m_VFX.SetFloat(m_BFreq, f_BFreq);
m_VFX.SetFloat(m_BLifetime, f_BLifetime);
m_VFX.SetFloat(m_BTurb, f_BTurb);
m_VFX.SetBool(m_BToggle, f_BToggle);
m_VFX.SetVector3(m_BForce, new Vector3(f_BForceX, f_BForceY, f_BForceZ));
}
}

11
Assets/Scripts/MidiMap.cs.meta

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

155
Assets/Timeline/MIDI Timeline.playable

@ -0,0 +1,155 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bfda56da833e2384a9677cd3c976a436, type: 3}
m_Name: MIDI Timeline
m_EditorClassIdentifier:
m_Version: 0
m_Tracks:
- {fileID: 2246285225922495411}
m_FixedDuration: 0
m_EditorSettings:
m_Framerate: 60
m_ScenePreview: 1
m_DurationMode: 0
m_MarkerTrack: {fileID: 0}
--- !u!114 &2246285225922495411
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d21dcc2386d650c4597f3633c75a1f98, type: 3}
m_Name: Animation Track
m_EditorClassIdentifier:
m_Version: 3
m_AnimClip: {fileID: 0}
m_Locked: 0
m_Muted: 0
m_CustomPlayableFullTypename:
m_Curves: {fileID: 0}
m_Parent: {fileID: 11400000}
m_Children: []
m_Clips:
- m_Version: 1
m_Start: 0
m_ClipIn: 0
m_Asset: {fileID: 4194534005624568023}
m_Duration: 341.569673708295
m_TimeScale: 1
m_ParentTrack: {fileID: 2246285225922495411}
m_EaseInDuration: 0
m_EaseOutDuration: 0
m_BlendInDuration: -1
m_BlendOutDuration: -1
m_MixInCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_MixOutCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
m_BlendInCurveMode: 0
m_BlendOutCurveMode: 0
m_ExposedParameterNames: []
m_AnimationCurves: {fileID: 0}
m_Recordable: 0
m_PostExtrapolationMode: 1
m_PreExtrapolationMode: 1
m_PostExtrapolationTime: Infinity
m_PreExtrapolationTime: 0
m_DisplayName: Scene
m_Markers:
m_Objects: []
m_InfiniteClipPreExtrapolation: 0
m_InfiniteClipPostExtrapolation: 0
m_InfiniteClipOffsetPosition: {x: 0, y: 0, z: 0}
m_InfiniteClipOffsetEulerAngles: {x: 0, y: 0, z: 0}
m_InfiniteClipTimeOffset: 0
m_InfiniteClipRemoveOffset: 0
m_InfiniteClipApplyFootIK: 1
mInfiniteClipLoop: 0
m_MatchTargetFields: 63
m_Position: {x: 0, y: 0, z: 0}
m_EulerAngles: {x: 0, y: 0, z: 0}
m_AvatarMask: {fileID: 0}
m_ApplyAvatarMask: 1
m_TrackOffset: 0
m_InfiniteClip: {fileID: 0}
m_OpenClipOffsetRotation: {x: 0, y: 0, z: 0, w: 1}
m_Rotation: {x: 0, y: 0, z: 0, w: 1}
m_ApplyOffsets: 0
--- !u!114 &4194534005624568023
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 030f85c3f73729f4f976f66ffb23b875, type: 3}
m_Name: AnimationPlayableAsset
m_EditorClassIdentifier:
m_Clip: {fileID: -623603649343465320, guid: 58aae735d649cbd4f9ae23a86c0d7e0a, type: 3}
m_Position: {x: 0, y: 0, z: 0}
m_EulerAngles: {x: 0, y: 0, z: 0}
m_UseTrackMatchFields: 1
m_MatchTargetFields: 63
m_RemoveStartOffset: 1
m_ApplyFootIK: 1
m_Loop: 0
m_Version: 1
m_Rotation: {x: 0, y: 0, z: 0, w: 1}

8
Assets/Timeline/MIDI Timeline.playable.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 219b44f685a6aa1428df393ac25c6755
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

16
ProjectSettings/TimelineSettings.asset

@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 53
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60
m_DefaultFrameRate: 60
Loading…
Cancel
Save