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
    public void SetSequencerNote(Toggle toggle)
    {
        int selected_idx = -1;

        for (int i = 0; i < patternElements.Length; i++)
        {
            if (patternElements[i] == toggle)
            {
                selected_idx = i;
                break;
            }
        }
        Debug.Log("selected_idx : " + selected_idx.ToString());
        if (selected_idx == -1)
        {
            Debug.Log("PatternHandler : SetSequencerNoteErr");
        }
        else
        {
            if (toggle.isOn == true)
            {
                AudioHelm.Note note = sequencer.AddNote(key, (selected_idx) / beatdivider, (selected_idx + 1) / beatdivider, velocity);
                existingNotes = sequencer.GetAllNotes();
                //Debug.Log("After AddNote : " + existingNotes.Count);
            }
            else
            {
                AudioHelm.Note existing_note = sequencer.GetNoteInRange(key, (selected_idx) / beatdivider, (selected_idx + 1) / beatdivider);
                sequencer.RemoveNote(existing_note);
                existingNotes.Remove(existing_note);
            }
        }
    }