コード例 #1
0
        public void Generate()
        {
            sequencer.Clear();

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

            for (int i = (int)typeOfSequence; i < sequencer.length; i += (int)typeOfSequence)
            {
                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 + (int)typeOfSequence);
                }
                else
                {
                    lastNote.end = i + (int)typeOfSequence;
                }
            }
        }
コード例 #2
0
    public void Edit(int columnIndex, int noteIndex)
    {
        NoteConfig noteConfig = noteConfigs[noteIndex];

        // Sequencer

        if (helmSequencer)
        {
            List <AudioHelm.Note> onNotes = helmSequencer.GetAllNoteOnsInRange(columnIndex, columnIndex + 1);
            foreach (AudioHelm.Note onNote in onNotes)
            {
                helmSequencer.RemoveNote(onNote);
            }

            //

            if (noteConfig.note != -1)
            {
                helmSequencer.AddNote(noteConfig.note, columnIndex, columnIndex + 1);
            }
        }

        // Sampler

        if (sampleSequencer)
        {
            List <AudioHelm.Note> onNotes = sampleSequencer.GetAllNoteOnsInRange(columnIndex, columnIndex + 1);
            foreach (AudioHelm.Note onNote in onNotes)
            {
                sampleSequencer.RemoveNote(onNote);
            }

            //

            if (noteConfig.note != -1)
            {
                sampleSequencer.AddNote(noteConfig.note, columnIndex, columnIndex + 1);
            }
        }

        //

        sequenceConfigs[columnIndex] = noteConfig;
    }