Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- float[] spectrum = AudioListener.GetSpectrumData(128, 0, FFTWindow.BlackmanHarris);
- float min_spec = Mathf.Min(spectrum);
- for (int idx = 0; idx < spectrum.Length; idx++)
- {
- spectrum[idx] -= min_spec;
- }
- float max_spec = Mathf.Max(spectrum);
- for (int idx = 0; idx < spectrum.Length; idx++)
- {
- spectrum[idx] /= max_spec;
- }
- float spec = 0f;
- for (int idx = 0; idx < spectrum.Length; idx++)
- {
- spec += spectrum[idx];
- }
- spec /= spectrum.Length * 0.35f;
- if (spec > 1) spec = 1;
- myScript.intensity = (0.5f-0.15f) * spec + 0.15f;
- //myScript.blurSize = (2.5f - 1.7f) * spec + 1.7f;
- }
Advertisement
Add Comment
Please, Sign In to add comment