Burnner

Untitled

Mar 25th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1.     void Update()
  2.     {
  3.         float[] spectrum = AudioListener.GetSpectrumData(128, 0, FFTWindow.BlackmanHarris);
  4.  
  5.         float min_spec = Mathf.Min(spectrum);
  6.         for (int idx = 0; idx < spectrum.Length; idx++)
  7.         {
  8.             spectrum[idx] -= min_spec;
  9.         }
  10.         float max_spec = Mathf.Max(spectrum);
  11.         for (int idx = 0; idx < spectrum.Length; idx++)
  12.         {
  13.             spectrum[idx] /= max_spec;
  14.         }
  15.  
  16.         float spec = 0f;
  17.         for (int idx = 0; idx < spectrum.Length; idx++)
  18.         {
  19.             spec += spectrum[idx];
  20.         }
  21.  
  22.         spec /= spectrum.Length * 0.35f;
  23.         if (spec > 1) spec = 1;
  24.  
  25.  
  26.         myScript.intensity = (0.5f-0.15f) * spec + 0.15f;
  27.         //myScript.blurSize = (2.5f - 1.7f) * spec + 1.7f;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment