Exemple #1
0
    void Update()
    {
        rootSinger.SetOffset(instrument.GetRootNote());
        thirdSinger.SetOffset(instrument.GetThirdNote());
        fifthSinger.SetOffset(instrument.GetFifthNote());
        highSinger.SetOffset(instrument.GetHighNote());

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            instrument.rootOffset = 0;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            instrument.rootOffset = 2;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            instrument.rootOffset = 4;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            instrument.rootOffset = 5;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            instrument.rootOffset = 7;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha6))
        {
            instrument.rootOffset = 9;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha7))
        {
            instrument.rootOffset = 11;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha8))
        {
            instrument.rootOffset = 12;
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            instrument.thirdOffset = -1;
        }
        else if (Input.GetKeyUp(KeyCode.Space))
        {
            instrument.thirdOffset = 0;
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            instrument.triangular = !instrument.triangular;
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            instrument.glissando = !instrument.glissando;
        }

        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            instrument.sustain = !instrument.sustain;
        }

        if (Input.GetKey(KeyCode.R))
        {
            instrument.highOffset = 4;
        }
        else if (Input.GetKey(KeyCode.E))
        {
            instrument.highOffset = 3;
        }
        else if (Input.GetKey(KeyCode.W))
        {
            instrument.highOffset = 2;
        }
        else if (Input.GetKey(KeyCode.Q))
        {
            instrument.highOffset = 1;
        }
        else if (Input.GetKey(KeyCode.F))
        {
            instrument.highOffset = -1;
        }
        else if (Input.GetKey(KeyCode.D))
        {
            instrument.highOffset = -2;
        }
        else if (Input.GetKey(KeyCode.S))
        {
            instrument.highOffset = -3;
        }
        else if (Input.GetKey(KeyCode.A))
        {
            instrument.highOffset = -4;
        }
        else
        {
            instrument.highOffset = 0;
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            PlayRootNote();
        }
        else if (Input.GetKeyUp(KeyCode.U))
        {
            StopRootNote();
        }
        if (Input.GetKeyDown(KeyCode.I))
        {
            PlayThirdNote();
        }
        else if (Input.GetKeyUp(KeyCode.I))
        {
            StopThirdNote();
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            PlayFifthNote();
        }
        else if (Input.GetKeyUp(KeyCode.O))
        {
            StopFifthNote();
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            PlayHighNote();
        }
        else if (Input.GetKeyUp(KeyCode.P))
        {
            StopHighNote();
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            PlayRootNote();
            PlayThirdNote();
            PlayFifthNote();
        }
        else if (Input.GetKeyUp(KeyCode.Return))
        {
            StopRootNote();
            StopThirdNote();
            StopFifthNote();
        }

#if UNITY_STANDALONE
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.Quit();
        }
#endif
    }