void Update()
    {
        if (backgroundThreadCompleted == true && threeDimensionalSpectrumBuild == false)
        {
            AudioSource.Play();             // CAN ONLY BE CALLED FROM MAIN THREAD
            Debug.Log("calling TestSpectrumBoy to build the thing!");
            threeDimensionalSpectrumBuild = true;
            Debug.Log(string.Format("threeDimensionalSpectrumBuild = ", threeDimensionalSpectrumBuild));

            // MAKE NEW
            SpectrumBoy.BuildVerticesSpectrum(0);
            SpectrumBoy.UpdateMesh();
            //SpectrumBoy.buildSpectrumGraph();
        }
        if (backgroundThreadCompleted == true && threeDimensionalSpectrumBuild == true)
        {
            // PLayer Movement -> Put thjis in right scritp !!
            // Forward / Backward
            float fwdSpeed   = 1f;
            float bckwdSpeed = 2f;             // Backward should be a little higher, because Audio is playing back. So if we go back 1 sec every sec, we actually stay in place
            if (Input.GetKey(KeyCode.Q))
            {
                AudioSource.time = AudioSource.time + fwdSpeed * Time.deltaTime;
            }

            if (Input.GetKey(KeyCode.E))
            {
                AudioSource.time = AudioSource.time - bckwdSpeed * Time.deltaTime;
            }

            Player.transform.position = new Vector3(Player.transform.position.x, Player.transform.position.y, songPositionToWorldPosition(AudioSource.time));

            // Manipulate Audio according to rotation (freq solo or mute)
            Debug.Log(Player.transform.eulerAngles.z);
            // We calculate the players current height against the outer Radius of our tunnel: When he is exactly at the lowest, the gain is 0, else it is 1 ("normal")
            float gain = (Player.GetComponent <PlayerMovement>().PlayerPosition.transform.localPosition.y / SpectrumBoy.outerRadius) * 1 + 1;
            // We set the frequency by calculating his rotation in euelerAngles (0 to 360) logarithmically against the 22.000 hz spectrum. This is kind of accurate.
            float freq = 22000f * (toLog(Player.transform.eulerAngles.z, 0.1f, 360) / 360);
            //AudioManipul8r.setMuteFreq(freq, gain);
            // We calculate the players current height against the outer Radius of our tunnel: When he is exactly at the lowest, the range is 0, else it is 22000f ("normal")

            Debug.Log(gain);
            float soloRange = toLog(gain, 0.01f, 1) * 22000f + 10;
            Debug.Log(soloRange);


            AudioManipul8r.setSoloFreq(freq, soloRange);

            // MAKE NEW
            SpectrumBoy.UpdateSpectrum(Player.transform.position.z);
            SpectrumBoy.UpdateMesh();
            // SpectrumBoy.updateSpectrumGraph(Player.transform.position.z);


            // SpectrumBoy.updateSpectrumGraph(AudioSource.time);
            // spectrumRealTime.updateRealTimeSpectrumGraph();
        }
    }
示例#2
0
    void Update()
    {
        // Confirm Chromesthesia Scene
        if (inChromesthestia)
        {
            if (backgroundThreadCompleted == true && threeDimensionalSpectrumBuild == false)
            {
                AudioSource.Play();                 // CAN ONLY BE CALLED FROM MAIN THREAD
                Debug.Log("calling TestSpectrumBoy to build the thing!");
                threeDimensionalSpectrumBuild = true;
                Debug.Log(string.Format("threeDimensionalSpectrumBuild = ", threeDimensionalSpectrumBuild));

                // MAKE NEW
                SpectrumBoy.BuildVerticesSpectrum(0);
                SpectrumBoy.UpdateMesh();
                //SpectrumBoy.buildSpectrumGraph();
                SpectrumBoy.GenerateHitPoints(Soundm8.preProcessedSpectralFluxAnalyzer.spectralFluxSamples);

                loadingScreen.SetActive(false);
            }
            if (backgroundThreadCompleted == true && threeDimensionalSpectrumBuild == true)
            {
                // Interactivity only when songs not finished
                if (songFinished == false)
                {
                    float currentSongTime = AudioSource.time;
                    Player.transform.position = new Vector3(Player.transform.position.x, Player.transform.position.y, songPositionToWorldPosition(currentSongTime));

                    /*
                     * AUDIO FX STUFF
                     */

                    // Manipulate Audio according to rotation (freq solo or mute)
                    // Debug.Log(Player.transform.eulerAngles.z);
                    // We calculate the players current height against the outer Radius of our tunnel: When he is exactly at the lowest, the gain is 0, else it is 1 ("normal")
                    float gain = (Player.GetComponent <PlayerMovement>().PlayerPosition.transform.localPosition.y / SpectrumBoy.outerRadius) * 1 + 1;
                    // We set the frequency by calculating his rotation in euelerAngles (0 to 360) logarithmically against the 22.000 hz spectrum. This is kind of accurate.
                    float freq = 22000f * (toLog(Player.transform.eulerAngles.z, 0.1f, 360) / 360);
                    AudioManipul8r.setMuteFreq(freq, gain);
                    // We calculate the players current height against the outer Radius of our tunnel: When he is exactly at the lowest, the range is 0, else it is 22000f ("normal")
                    // Debug.Log(gain);
                    float soloRange = toLog(gain, 0.01f, 1) * 22000f + 10;
                    // Debug.Log(soloRange);


                    AudioManipul8r.setSoloFreq(freq, soloRange);

                    // MAKE NEW
                    SpectrumBoy.UpdateSpectrum(Player.transform.position.z);
                    SpectrumBoy.UpdateMesh();
                    // Always call after UpdateSpectrum !!
                    SpectrumBoy.updateRealTimeCanvas(currentSongTime);

                    // SpectrumBoy.updateSpectrumGraph(Player.transform.position.z);


                    // SpectrumBoy.updateSpectrumGraph(AudioSource.time);
                    // spectrumRealTime.updateRealTimeSpectrumGraph();

                    // check if song is finished
                    if (currentSongTime + 2 >= AudioSource.clip.length)
                    {
                        songFinished = true;
                    }
                }
                // When song is finished
                else
                {
                    // Go back to SelectScene
                    SceneManager.LoadScene("SelectScene");
                }
            }
        }
    }