using UnityEngine; namespace Crosstales.Common.Audio { /// FFT analyzer for an audio channel. public class FFTAnalyzer : MonoBehaviour { #region Variables ///Array for the samples. More samples mean better accuracy but it also needs more performance (default: 256). [Tooltip("Array for the samples. More samples mean better accuracy but it also needs more performance (default: 256)")] public float[] Samples = new float[256]; ///Analyzed channel (0 = right, 1 = left, default: 0). [Tooltip("Analyzed channel (0 = right, 1 = left, default: 0).")] [Range(0, 1)] public int Channel; ///FFT-algorithm to analyze the audio (default: BlackmanHarris). [Tooltip("FFT-algorithm to analyze the audio (default: BlackmanHarris).")] public FFTWindow FFTMode = FFTWindow.BlackmanHarris; #endregion #region MonoBehaviour methods private void Update() { AudioListener.GetSpectrumData(Samples, Channel, FFTMode); } #endregion } } // © 2015-2020 crosstales LLC (https://www.crosstales.com)