GetScaledOutput() public static method

public static GetScaledOutput ( int listenBand, float bandMax, float targetMin, float targetMax ) : float
listenBand int
bandMax float
targetMin float
targetMax float
return float
コード例 #1
0
 void Update()
 {
     for (int i = 0; i < mats.Length; i++)
     {
         mats[i].color = Color.Lerp(low, high, AudioAnalyzer.GetScaledOutput(band, maxInput, .1f, 1f));
     }
     rend.materials = mats;
 }
コード例 #2
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            SceneManager.LoadScene(0);
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            SceneManager.LoadScene(1);
        }
        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }

        amplitude = AudioAnalyzer.GetScaledOutput(0, Config.limits.x, Config.limits.y);

        //currentPitch = float.MinValue;

        //if (amplitudeAverage > Config.AmplitudeMin)
        //{
        //       float out0 = AudioAnalyzer.GetScaledOutput(0, 0f, 1f);
        //       float out1 = AudioAnalyzer.GetScaledOutput(1, 0f, 1f);
        //       float out2 = AudioAnalyzer.GetScaledOutput(2, 0f, 1f);
        //       float out3 = AudioAnalyzer.GetScaledOutput(3, 0f, 1f);
        //       float out4 = AudioAnalyzer.GetScaledOutput(4, 0f, 1f);
        //       float out5 = AudioAnalyzer.GetScaledOutput(5, 0f, 1f);
        //       float out6 = AudioAnalyzer.GetScaledOutput(6, 0f, 1f);
        //       float out7 = AudioAnalyzer.GetScaledOutput(7, 0f, 1f);
        //       float out8 = AudioAnalyzer.GetScaledOutput(8, 0f, 1f);
        //       float out9 = AudioAnalyzer.GetScaledOutput(9, 0f, 1f);

        //       currentPitch =                out0 * 4.5f; //  12.5f Max
        //    currentPitch = currentPitch + out1 * 3.5f;
        //    currentPitch = currentPitch + out2 * 2.5f;
        //    currentPitch = currentPitch + out3 * 1.5f;
        //    currentPitch = currentPitch + out4 * 0.5f;
        //    currentPitch = currentPitch - out5 * 0.5f;
        //    currentPitch = currentPitch - out6 * 1.5f;
        //    currentPitch = currentPitch - out7 * 2.5f;
        //    currentPitch = currentPitch - out8 * 3.5f;
        //    currentPitch = currentPitch - out9 * 4.5f; // -12.5f Min

        //    currentPitch = (currentPitch + 12.5f) / 25f;
        //   }

        //currentPitchHeight = Config.PitchSpan * currentPitch;
        if (amplitude > Config.AmplitudeMin)
        {
            currentPitchHeight = Config.PitchSpan * amplitude;
        }
        else
        {
            currentPitchHeight = float.MinValue;
        }

        Debug.Log("AmplitudeAvg: " + amplitude + " currentPitchHeight: " + currentPitchHeight);
    }