Commit a7256bb1 authored by Nathan De Castro's avatar Nathan De Castro

Cleaned up code and sorted pith detection

parent 2a8caa54
......@@ -93,9 +93,11 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\FisheyeShader.shader" />
<None Include="Assets\Materials\Monster\shaders\vertexAnim.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Apply.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe Functions.cginc" />
<None Include="Assets\SteamVR\InteractionSystem\Teleport\Shaders\Highlight.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......@@ -132,6 +134,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VortexEffect.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Adaptation.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\NoiseAndGrain.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\Projectors\Shaders\ProjectorMultiply.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VignettingShader.shader" />
<None Include="Assets\SteamVR\Resources\SteamVR_SphericalProjection.shader" />
......@@ -139,8 +142,10 @@
<None Include="Assets\SteamVR\Resources\SteamVR_AlphaOut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BrightPassFilter.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA2.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrection3DLut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\LensFlareCreate.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\EdgeDetectNormals.shader" />
<None Include="Assets\SteamVR\readme.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\PrepareSunShaftsBlur.shader" />
......@@ -156,6 +161,9 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\SteamVR\InteractionSystem\Readme_InteractionSystem.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath>
</Reference>
......@@ -198,6 +206,9 @@
<Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath>
</Reference>
......
......@@ -88,9 +88,11 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\FisheyeShader.shader" />
<None Include="Assets\Materials\Monster\shaders\vertexAnim.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Apply.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe Functions.cginc" />
<None Include="Assets\SteamVR\InteractionSystem\Teleport\Shaders\Highlight.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......@@ -127,6 +129,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VortexEffect.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Adaptation.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\NoiseAndGrain.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\Projectors\Shaders\ProjectorMultiply.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VignettingShader.shader" />
<None Include="Assets\SteamVR\Resources\SteamVR_SphericalProjection.shader" />
......@@ -134,8 +137,10 @@
<None Include="Assets\SteamVR\Resources\SteamVR_AlphaOut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BrightPassFilter.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA2.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrection3DLut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\LensFlareCreate.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\EdgeDetectNormals.shader" />
<None Include="Assets\SteamVR\readme.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\PrepareSunShaftsBlur.shader" />
......@@ -154,6 +159,9 @@
<Reference Include="Assembly-UnityScript">
<HintPath>C:/Users/yuki/Documents/Work/Listen/Library/ScriptAssemblies/Assembly-UnityScript.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/Editor/UnityEditor.Advertisements.dll</HintPath>
</Reference>
......@@ -196,6 +204,9 @@
<Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEditor.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll</HintPath>
</Reference>
......
......@@ -156,9 +156,11 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\FisheyeShader.shader" />
<None Include="Assets\Materials\Monster\shaders\vertexAnim.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Apply.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe Functions.cginc" />
<None Include="Assets\SteamVR\InteractionSystem\Teleport\Shaders\Highlight.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......@@ -195,6 +197,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VortexEffect.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Adaptation.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\NoiseAndGrain.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\Projectors\Shaders\ProjectorMultiply.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VignettingShader.shader" />
<None Include="Assets\SteamVR\Resources\SteamVR_SphericalProjection.shader" />
......@@ -202,8 +205,10 @@
<None Include="Assets\SteamVR\Resources\SteamVR_AlphaOut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BrightPassFilter.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA2.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrection3DLut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\LensFlareCreate.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\EdgeDetectNormals.shader" />
<None Include="Assets\SteamVR\readme.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\PrepareSunShaftsBlur.shader" />
......@@ -219,6 +224,9 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\SteamVR\InteractionSystem\Readme_InteractionSystem.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference>
......@@ -234,6 +242,9 @@
<Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath>
</Reference>
......
......@@ -60,6 +60,7 @@
<Compile Include="Assets\Scripts\Tools\AM.cs" />
<Compile Include="Assets\Scripts\Tools\FPS_Camera.cs" />
<Compile Include="Assets\Scripts\Tools\FPS_Control.cs" />
<Compile Include="Assets\Scripts\Tools\FadeInAndOut.cs" />
<Compile Include="Assets\Scripts\Tools\GameSettings.cs" />
<Compile Include="Assets\Scripts\Tools\GhostSound.cs" />
<Compile Include="Assets\Scripts\Tools\LightScript.cs" />
......@@ -210,9 +211,11 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\FisheyeShader.shader" />
<None Include="Assets\Materials\Monster\shaders\vertexAnim.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Apply.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe Functions.cginc" />
<None Include="Assets\SteamVR\InteractionSystem\Teleport\Shaders\Highlight.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\frag_ao.cginc" />
<None Include="Assets\Materials\Monster\shaders\bumpSpecmap.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Wireframe.shader" />
<None Include="Assets\Materials\Monster\shaders\metalA.shader" />
<None Include="Assets\Standard Assets\Effects\ToonShading\Shaders\ToonBasicOutline.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_DepthOfField\DepthOfField34.shader" />
......@@ -249,6 +252,7 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VortexEffect.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\Contrast Stretch\Adaptation.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\NoiseAndGrain.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\Projectors\Shaders\ProjectorMultiply.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\VignettingShader.shader" />
<None Include="Assets\SteamVR\Resources\SteamVR_SphericalProjection.shader" />
......@@ -256,8 +260,10 @@
<None Include="Assets\SteamVR\Resources\SteamVR_AlphaOut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BrightPassFilter.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_Antialiasing\FXAA2.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\ColorCorrection3DLut.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\LensFlareCreate.shader" />
<None Include="Assets\UCLAGameLab\Wireframe\Shaders\UCLA GameLab Double-Sided Cutout Wireframe.shader" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\EdgeDetectNormals.shader" />
<None Include="Assets\SteamVR\readme.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\PrepareSunShaftsBlur.shader" />
......@@ -273,6 +279,9 @@
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlurAndFlares.shader" />
<None Include="Assets\SteamVR\InteractionSystem\Readme_InteractionSystem.txt" />
<None Include="Assets\Standard Assets\Effects\ImageEffects\Shaders\_BloomAndFlares\BlendForBloom.shader" />
<Reference Include="UnityEngine.Advertisements">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/Advertisements/UnityEngine.Advertisements.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll</HintPath>
</Reference>
......@@ -288,6 +297,9 @@
<Reference Include="UnityEngine.HoloLens">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.Purchasing">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityPurchasing/UnityEngine.Purchasing.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.VR">
<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/RuntimeEditor/UnityEngine.VR.dll</HintPath>
</Reference>
......
......@@ -8,10 +8,11 @@ Material:
m_PrefabInternal: {fileID: 0}
m_Name: Floor
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _EMISSION
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
......@@ -81,7 +82,7 @@ Material:
second: 1
- first:
name: _DstBlend
second: 0
second: 10
- first:
name: _GlossMapScale
second: 1
......@@ -96,7 +97,7 @@ Material:
second: 0
- first:
name: _Mode
second: 0
second: 3
- first:
name: _OcclusionStrength
second: 1
......@@ -117,7 +118,7 @@ Material:
second: 0
- first:
name: _ZWrite
second: 1
second: 0
m_Colors:
- first:
name: _Color
......
......@@ -2,22 +2,42 @@ using UnityEngine;
// A simple rotating script for the walls of the player area
public class BigEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
public float volume_threshold = 20.0f;
public float pitch_threshold = 0.1f;
public float fade_speed = 0.5f;
public bool volume_based = true;
public bool pitch_based = false;
private bool Activated = false;
private FadeInAndOut enabler;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
enabler = GetComponent<FadeInAndOut> ();
}
// Update is called once per frame
void Update () {
if (AM.i.GetRMS () > 10.0f) {
volume_based = !pitch_based;
pitch_based = !volume_based;
if (volume_based) {
if (AM.i.GetRMS () > volume_threshold && Activated == false) {
Activated = true;
} else {
enabler.FadeIn (fade_speed);
} else if (AM.i.GetRMS () < volume_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
if (pitch_based) {
if (AM.i.GetComplexPitch ()[2] > pitch_threshold && Activated == false) {
Activated = true;
enabler.FadeIn (fade_speed);
} else if (AM.i.GetComplexPitch ()[2] < pitch_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
}
}
\ No newline at end of file
......@@ -2,22 +2,42 @@ using UnityEngine;
// A simple rotating script for the walls of the player area
public class MediumEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
public float volume_threshold = 10.0f;
public float pitch_threshold = 0.1f;
public float fade_speed = 0.5f;
public bool volume_based = true;
public bool pitch_based = false;
private bool Activated = false;
private FadeInAndOut enabler;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
enabler = GetComponent<FadeInAndOut> ();
}
// Update is called once per frame
void Update () {
if (AM.i.GetRMS () > 6.0f) {
volume_based = !pitch_based;
pitch_based = !volume_based;
if (volume_based) {
if (AM.i.GetRMS () > volume_threshold && Activated == false) {
Activated = true;
} else {
enabler.FadeIn (fade_speed);
} else if (AM.i.GetRMS () < volume_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
if (pitch_based) {
if (AM.i.GetComplexPitch ()[1] > pitch_threshold && Activated == false) {
Activated = true;
enabler.FadeIn (fade_speed);
} else if (AM.i.GetComplexPitch ()[1] < pitch_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
}
}
\ No newline at end of file
......@@ -2,22 +2,42 @@ using UnityEngine;
// A simple rotating script for the walls of the player area
public class SmallEnabler : MonoBehaviour {
public bool Activated = false;
Renderer[] rendererComponents;
public float volume_threshold = 3.0f;
public float pitch_threshold = 0.1f;
public float fade_speed = 0.5f;
public bool volume_based = true;
public bool pitch_based = false;
private bool Activated = false;
private FadeInAndOut enabler;
void Start () {
rendererComponents = GetComponentsInChildren<Renderer> ();
enabler = GetComponent<FadeInAndOut> ();
}
// Update is called once per frame
void Update () {
if (AM.i.GetRMS () > 2.0f) {
volume_based = !pitch_based;
pitch_based = !volume_based;
if (volume_based) {
if (AM.i.GetRMS () > volume_threshold && Activated == false) {
Activated = true;
} else {
enabler.FadeIn (fade_speed);
} else if (AM.i.GetRMS () < volume_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
foreach (Renderer component in rendererComponents) {
component.enabled = Activated;
if (pitch_based) {
if (AM.i.GetComplexPitch ()[0] > pitch_threshold && Activated == false) {
Activated = true;
enabler.FadeIn (fade_speed);
} else if (AM.i.GetComplexPitch ()[0] < pitch_threshold && Activated == true) {
Activated = false;
enabler.FadeOut (fade_speed);
}
}
}
}
\ No newline at end of file
......@@ -7,9 +7,13 @@ public class SwitchState : MonoBehaviour {
public GameObject switch_off;
static public bool switch_status;
static public bool player_near_switch;
public bool start_with_light = true;
// Use this for initialization
void Start () {
if (start_with_light)
main_light.enabled = true;
else
main_light.enabled = false;
}
......
......@@ -5,29 +5,36 @@ public class AM : MonoBehaviour {
public static AM i;
private AudioSource mic_source;
public GameObject cube;
//Globals
public bool pitch_based = false;
public float color_range_min = 3;
public float color_range_max = 40;
public bool use_pitch = false;
public float light_angle_scaler = 20;
public float light_angle_max = 130;
public float splash_force_scaler = 100;
public int buffer_size = 64;
public float audio_update_rate = 40.0f;
private float[] spec_data;
private float[] samp_data;
private int spec_size = 1024;
private int samp_size = 1024;
private int buffer_size = 44100;
private float rms;
private float vol;
private float max_energy_bin = 0;
private float average_pitch = 0;
private float low_pitch = 0;
private float med_pitch = 0;
private float high_pitch = 0;
private float[] spec_data;
private float average_pitch_low = 0;
private float average_pitch_mid = 0;
private float average_pitch_high = 0;
// private float low_pitch = 0;
// private float med_pitch = 0;
// private float high_pitch = 0;
void Start () {
i = this;
spec_data = new float[spec_size];
samp_data = new float[samp_size];
//Sets up the audiosource to use the Microphone
mic_source = GetComponent<AudioSource> ();
......@@ -37,23 +44,27 @@ public class AM : MonoBehaviour {
mic_source.Play (); //starts the playback
mic_source.volume = 0.5f; //Mutes the audiosource
spec_data = new float[buffer_size];
InvokeRepeating ("PitchAnalysis", 0, 1.0f / audio_update_rate); // Updates at 40 fps
InvokeRepeating ("AmplitudeAnalysis", 0, 1.0f / audio_update_rate); //Updates at 40 fps
InvokeRepeating ("BufferPopulator", 0, 1.0f / audio_update_rate); //Begins another thread
}
void FixedUpdate () {
AmplitudeAnalysis ();
AveragePitchAnalysis ();
//ComplexPitchAnalysis ();
}
public void BufferPopulator () {
AudioListener.GetSpectrumData (spec_data, 0, FFTWindow.Hamming);
mic_source.clip.GetData (samp_data, 0);
}
//Anaylsis function:
public void AmplitudeAnalysis () {
int buf_size = buffer_size;
float[] samp_data = new float[buf_size]; //Creates an array pre-allocated (We want it quite small to reduce latency, I made it tweakable from the inspector)
mic_source.clip.GetData (samp_data, 0); //Stores all the output data into the array I pre-allocated
float vol_sum = 0;
for (int i = 0; i < buf_size; i++) {
for (int i = 0; i < samp_size; i++) {
vol_sum += Mathf.Abs (samp_data[i] * samp_data[i]); //Calculates the square sum of all the data
}
rms = Mathf.