Esempio n. 1
0
        private void LoopInCallback(object sender, IMidiEventArgs e)
        {
            var noteOn = e.MidiEvent.Message as MidiNoteMessage;

            if (noteOn != null && noteOn.Channel == 2 && noteOn.Command == EMidiCommand.NoteOn && noteOn.Note == 63 && noteOn.Velocity == 100)
            {
                loopGotShortMessage = true;
                return;
            }

            var sysex = e.MidiEvent.Message as MidiSysexMessage;
            var comp  = new byte[] { 0xF0, 0x55, 0x15, 0x02, 0x19, 0x64, 0xF7 };

            if (sysex != null && sysex.Body.Length == comp.Length)
            {
                for (int i = 0; i < sysex.Body.Length; i++)
                {
                    if (comp[i] != sysex.Body[i])
                    {
                        throw new InvalidOperationException("Loop test: Unexpexted sysex data at offset " + i);
                    }
                }

                loopGotLongMessage = true;
                return;
            }

            throw new InvalidOperationException("Loop test: Got unknown message on loop input: " + e.MidiEvent.Message);
        }
Esempio n. 2
0
 // Midi events callback: activate the midiInput event
 public void MidiInCallback(object sender, IMidiEventArgs e)
 {
     if (midiInput != null && e.MidiEvent.Message != null)
     {
         midiInput.Invoke(this, new MidiInputEventArgs(e.MidiEvent.Message));
     }
 }
Esempio n. 3
0
 void MidiInTest_MidiInputReceived(object sender, IMidiEventArgs e)
 {
     if (e.MidiEvent.Message is MidiNoteMessage mnm)
     {
         if (mnm.Action == EMidiNoteAction.On)
         {
             numNoteOn += 1;
         }
         else if (mnm.Action == EMidiNoteAction.Off)
         {
             numNoteOff += 1;
         }
     }
 }