Esempio n. 1
0
    public void Generate()
    {
        var       celProps  = this.gameObject.GetComponent <celestialProperties>();
        Sequencer sequencer = this.gameObject.GetComponent <HelmSequencer>();

        sequencer.Clear();

        int  maxNote     = scale.Length * octaveSpan;
        int  currentNote = Random.Range(0, maxNote);
        Note lastNote    = sequencer.AddNote(GetKeyFromRandomWalk(currentNote), 0, 1);

        for (int i = 1; i < sequencer.length; ++i)
        {
            float density = Random.Range(minDensity, maxDensity);

            if (Random.Range(0.0f, 1.0f) < density)
            {
                currentNote = GetNextNote(currentNote, maxNote);
                lastNote    = sequencer.AddNote(GetKeyFromRandomWalk(currentNote), i, i + 1);
            }
            else
            {
                lastNote.end = i + 1;
            }
        }
    }
Esempio n. 2
0
    // Start is called before the first frame update
    void Start()
    {
        patternElements = GetComponentsInChildren <Toggle>();
        Debug.Log("NoteSet # of toggle : " + patternElements.Length);
        count = 0;

        clock = GameObject.Find("Clock").GetComponent <AudioHelmClock>();

        //GameObject DrumSequencer = GameObject.Find("DrumKit01Sequencer");
        //GameObject SynthSequencer = GameObject.Find("SynthSequencer");
        //GameObject BassSequencer = GameObject.Find("BassSequencer");
        //GameObject GuitarSequencer = GameObject.Find("GuitarSequencer");


        CatList Catlist = GameObject.Find("CatList").GetComponent <CatList>();

        currentCat   = Catlist.catlist[Catlist.catlist.Count - 1];
        positionText = GameObject.Find("Position").GetComponent <Text>();


        print(currentCat.instrumentName);

        if (currentCat.instrumentName == "drum")
        {
            sequencer = GameObject.Find("DrumKit01Sequencer").GetComponent <Sequencer>();
        }
        else if (currentCat.instrumentName == "synthesizer")
        {
            sequencer = GameObject.Find("SynthSequencer").GetComponent <Sequencer>();
        }
        else if (currentCat.instrumentName == "bass")
        {
            print("Get into the bass");
            sequencer = GameObject.Find("BassSequencer").GetComponent <Sequencer>();
            //patch = GameObject.Find("basspatch").GetComponent<HelmPatch>();
            //print(patch);

            //print(GameObject.Find("BassSequencer").GetComponent<HelmController>());
            //GameObject.Find("BassSequencer").GetComponent<HelmController>().LoadPatch(patch);
            key = key - 12;
        }
        else if (currentCat.instrumentName == "guitar")
        {
            sequencer = GameObject.Find("GuitarSequencer").GetComponent <Sequencer>();
        }
        else
        {
            print("this is not good");
        }

        switch (currentCat.catType)
        {
        case "plain":
            velocity    = 0.7f;
            beat        = 16;
            beatdivider = 1f;
            break;

        case "strong":
            velocity    = 1.0f;
            beat        = 16;
            beatdivider = 1f;
            break;

        case "sensitive":
            velocity    = 0.4f;
            beat        = 16;
            beatdivider = 1f;
            break;

        case "supreme":
            velocity    = 0.7f;
            beat        = 32;
            beatdivider = 2f;
            break;

        default:
            break;
        }

        ResetButton = GameObject.Find("ResetButton").GetComponent <Button>();

        if (sequencer == null)
        {
            print("null!");
        }
        sequencer.Clear();
        Color normalColor = patternElements[0].colors.normalColor;

        initColor = new Color(normalColor.r, normalColor.g, normalColor.b);

        ResetButton.onClick.AddListener(delegate
        {
            ResetNote();
        });
        sequencer.beatEvent.AddListener(delegate
        {
            ToggleBackgroundChange();
        });
        //sequencer.
        //Pattern Color Selection
        //if (InstName == "Bass Drum") {
        //    for (int )
        //}
    }