Implemented 3d keyboard to visualise MIDI notes from our PD patch.
This commit is contained in:
parent
79c7e7c65a
commit
dfe695d31a
6 changed files with 2762 additions and 0 deletions
|
|
@ -68,6 +68,7 @@
|
||||||
<Compile Include="Assets\Scripts\LibPd2UnitySceneScripts\EnvelopeFollower.cs" />
|
<Compile Include="Assets\Scripts\LibPd2UnitySceneScripts\EnvelopeFollower.cs" />
|
||||||
<Compile Include="Assets\Scripts\LibPdInstance.cs" />
|
<Compile Include="Assets\Scripts\LibPdInstance.cs" />
|
||||||
<Compile Include="Assets\Scripts\MidiSceneScripts\Button2Midi.cs" />
|
<Compile Include="Assets\Scripts\MidiSceneScripts\Button2Midi.cs" />
|
||||||
|
<Compile Include="Assets\Scripts\MidiSceneScripts\Midi2Unity.cs" />
|
||||||
<Compile Include="Assets\Scripts\PlayerMovement.cs" />
|
<Compile Include="Assets\Scripts\PlayerMovement.cs" />
|
||||||
<Compile Include="Assets\Scripts\SpatialisationSceneScripts\CircleMotion.cs" />
|
<Compile Include="Assets\Scripts\SpatialisationSceneScripts\CircleMotion.cs" />
|
||||||
<Compile Include="Assets\Scripts\Teleport.cs" />
|
<Compile Include="Assets\Scripts\Teleport.cs" />
|
||||||
|
|
|
||||||
77
Assets/Materials/Black Keys Material.mat
Normal file
77
Assets/Materials/Black Keys Material.mat
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: Black Keys Material
|
||||||
|
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BumpMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailMask:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNormalMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _EmissionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MetallicGlossMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _OcclusionMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ParallaxMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _BumpScale: 1
|
||||||
|
- _Cutoff: 0.5
|
||||||
|
- _DetailNormalMapScale: 1
|
||||||
|
- _DstBlend: 0
|
||||||
|
- _GlossMapScale: 1
|
||||||
|
- _Glossiness: 0.5
|
||||||
|
- _GlossyReflections: 1
|
||||||
|
- _Metallic: 0
|
||||||
|
- _Mode: 0
|
||||||
|
- _OcclusionStrength: 1
|
||||||
|
- _Parallax: 0.02
|
||||||
|
- _SmoothnessTextureChannel: 0
|
||||||
|
- _SpecularHighlights: 1
|
||||||
|
- _SrcBlend: 1
|
||||||
|
- _UVSec: 0
|
||||||
|
- _ZWrite: 1
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
8
Assets/Materials/Black Keys Material.mat.meta
Normal file
8
Assets/Materials/Black Keys Material.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 59af0a808a0b5d84c8458f10e27bba64
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 2100000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load diff
69
Assets/Scripts/MidiSceneScripts/Midi2Unity.cs
Normal file
69
Assets/Scripts/MidiSceneScripts/Midi2Unity.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
// Midi2Unity.cs - Script to visualise MIDI input from our PD patch.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2020 Niall Moody
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>Script to visualise MIDI input from our PD patch.</summary>
|
||||||
|
///
|
||||||
|
/// <remarks>This script does 2 things:
|
||||||
|
///
|
||||||
|
/// 1.) Toggles note playback when the player enters/exits the trigger volume.
|
||||||
|
///
|
||||||
|
/// 2.) Visualises incoming MIDI notes from our PD patch.</remarks>
|
||||||
|
public class Midi2Unity : MonoBehaviour
|
||||||
|
{
|
||||||
|
/// Our PD patch.
|
||||||
|
public LibPdInstance pdPatch;
|
||||||
|
|
||||||
|
/// Our 12 note lights.
|
||||||
|
public GameObject[] lights;
|
||||||
|
|
||||||
|
/// This will get called for every note on/off message we receive from our patch.
|
||||||
|
public void NoteReceived(int channel, int note, int velocity)
|
||||||
|
{
|
||||||
|
int wrappedNote = note % 12;
|
||||||
|
|
||||||
|
for(int i=0;i<lights.Length;++i)
|
||||||
|
lights[i].SetActive(false);
|
||||||
|
|
||||||
|
if(lights.Length > wrappedNote)
|
||||||
|
{
|
||||||
|
lights[wrappedNote].SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Toggle note playback when player enters trigger volume.
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
pdPatch.SendBang("Toggle");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Toggle note playback when player exits trigger volume.
|
||||||
|
private void OnTriggerExit(Collider other)
|
||||||
|
{
|
||||||
|
for(int i=0;i<lights.Length;++i)
|
||||||
|
lights[i].SetActive(false);
|
||||||
|
|
||||||
|
pdPatch.SendBang("Toggle");
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/MidiSceneScripts/Midi2Unity.cs.meta
Normal file
11
Assets/Scripts/MidiSceneScripts/Midi2Unity.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e2f4ee11f4056f40b6dfb948ad73e52
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Reference in a new issue