コード例 #1
0
 void NoteOff(int index)
 {
     if (synth)
     {
         synth.NoteOff(GetKeyFromIndex(48 + index));
     }
 }
コード例 #2
0
    // ------------------------------ Public functions ------------------------------



    /// <summary>
    /// Change controller channel and sequencer reference.
    /// </summary>
    /// <param name="layer"></param>
    public void ChangeLayer(int layer)
    {
        bool isPlaying      = Player.inst.actionState == Player.ActionState.Play;
        var  sequencerPos   = (float)curSequencer.GetSequencerPosition();
        var  sequencerNotes = MyAudioHelmHelper.GetCurrentNotes(curSequencer, sequencerPos);

        // 1. Stop curChord (if not being played in the sequencer)
        if (isPlaying)
        {
            foreach (int curNote in curChord.notes)
            {
                bool isPlayedInSequencer = false;
                foreach (Note seqNote in sequencerNotes)
                {
                    if (curNote == seqNote.note)
                    {
                        isPlayedInSequencer = true;
                        break;
                    }
                }

                if (!isPlayedInSequencer)
                {
                    controller.NoteOff(curNote);
                }
            }
        }

        // 2. Change sequencer & controller reference
        curSequencer       = Recorder.inst.sequencers[layer];
        controller.channel = layer;
    }
コード例 #3
0
    public static void PlayChord(Chord chord, HelmController controller, float velocity)
    {
        for (int i = 0; i < chord.notes.Length; i++)
        {
            int note = chord.notes[i];
            if (controller.IsNoteOn(note))
            {
                controller.NoteOff(note);
            }

            controller.NoteOn(note, velocity);
        }
    }
コード例 #4
0
 public static void StopChord(Chord chord, HelmController controller, Sequencer sequencer, bool forceNoteOff = false)
 {
     for (int i = 0; i < chord.notes.Length; i++)
     {
         int note = chord.notes[i];
         if (controller.IsNoteOn(note))
         {
             // 2. Stop only if the notes are NOT being played in the sequencer
             if (!sequencer.IsNoteOn(note) || forceNoteOff)
             {
                 controller.NoteOff(note);
             }
         }
     }
 }