Example #1
0
    void Update()
    {
        if (!isInitialized || !csoundUnity.IsInitialized)
        {
            return;
        }

        if (Input.GetKeyDown("1"))
        {
            csoundUnity.SendScoreEvent("i\"ClearSequencer\" 0 0 ");
            Invoke("updateSequencerGUI", .1f);
        }

        if (Input.GetKeyDown("2"))
        {
            csoundUnity.SendScoreEvent("i\"RandomSequencer\" 0 0 ");
            Invoke("updateSequencerGUI", .1f);
        }


        if (csoundUnity)
        {
            csoundUnity.SetChannel("BPM", BPM);
        }

        if (beatNumber != csoundUnity.GetChannel("beatNumber"))
        {
            beatNumber = (int)csoundUnity.GetChannel("beatNumber");

            if (showSequencerGUI)
            {
                for (int voice = 0; voice < numberOfVoices; voice++)
                {
                    for (int beat = 0; beat < numberOfBeats; beat++)
                    {
                        if (beat == beatNumber)
                        {
                            pads[beat + (voice * numberOfBeats)].transform.localScale = new Vector3(0.8f, 0.8f, 0.1f);
                        }

                        else
                        {
                            pads[beat + (voice * numberOfBeats)].transform.localScale = new Vector3(0.5f, 0.5f, 0.1f);
                        }
                    }
                }
            }
        }
    }