コード例 #1
0
 void Update()
 {
     if (currentIndex < data.frames.Count)
     {
         var frame = data.frames[currentIndex];
         for (int i = 0; i < frame.Count; i++)
         {
             float freq = SpectrumData.IndexToFrequency(frame.index[i]);
             float gain = frame.level[i];
             SetParameter(i, freq, gain);
         }
         for (int i = frame.Count; i < SpectrumData.PEAKS; i++)
         {
             SetParameter(i, 50, 0);
         }
     }
     currentIndex++;
 }
コード例 #2
0
        void OnGLDraw()
        {
            GL.Begin(GL.LINES);
            GL.Color(Color.red);

            if (currentIndex < data.frames.Count)
            {
                float width  = Screen.width;
                float height = Screen.height;
                float offset = 0;

                var frame = data.frames[currentIndex];
                for (int i = frame.Count - 1; i >= 0; i--)
                {
                    float freq = SpectrumData.IndexToFrequency(frame.index[i]);
                    float x    = Mathf.InverseLerp(0, 22050, freq) * width;
                    float y    = frame.level[i] * height * 10;
                    GL.Vertex3(x, offset, 0);
                    GL.Vertex3(x, offset + y, 0);
                }
            }

            GL.End();
        }