Exemplo n.º 1
0
        protected override float[] Process1(AudioBuffer input)
        {
            var data   = input.Current.data.ToArray();
            int length = Mathf.FloorToInt(data.Length / (float)binSize);

            float[] energy = new float[length];
            for (int j = 0; j < length; j++)
            {
                for (int i = j * binSize; i < data.Length && i < (j + 1) * binSize; i++)
                {
                    energy[j] += data[i] * data[i];
                }
                energy[j] /= (float)binSize;
                peak       = Mathf.Max(peak, energy[j]);
            }
            for (int j = 0; j < length; j++)
            {
                energy[j] /= peak;
            }
            return(energy);
        }
Exemplo n.º 2
0
 protected abstract Return Process1(AudioBuffer data);
Exemplo n.º 3
0
 public void CreateBuffer()
 {
     data    = new float[windowSize];
     Buffer  = new AudioBuffer(bufferSize, SampleRate, data.Length);
     texture = new Texture2D(windowSize, bufferSize, TextureFormat.Alpha8, false);
 }