public static bool Present() { int num_in = Midi.MidiInGetNumDevs(); for (int i = 0; i < num_in; i++) { string s = Midi.MidiInGetName(i); //if(s == "FLEX 5000" || s == "FLEX-5000 Midi" || s == "FlexRadio Flex-5000" || s == "FlexRadio Flex-5000 MIDI") if (s.IndexOf("FLEX") >= 0 || s.IndexOf("Flex") >= 0) { goto test_out; } } //log.AddLine("Midi.Present(): False (no input dev)"); return(false); test_out: int num_out = Midi.MidiOutGetNumDevs(); for (int i = 0; i < num_out; i++) { string s = Midi.MidiOutGetName(i); //if(s == "FLEX 5000" || s == "2- FLEX-5000 Midi" || s == "FlexRadio Flex-5000" || s == "2- FlexRadio Flex-5000 MIDI") if (s.IndexOf("FLEX") >= 0 || s.IndexOf("Flex") >= 0) { return(true); } } //log.AddLine("Midi.Present(): False (no output dev)"); return(false); }
private static bool OpenMidiIn() { int num_in = Midi.MidiInGetNumDevs(); int in_index = -1; for (int i = 0; i < num_in; i++) { string s = Midi.MidiInGetName(i); //if(s == "FLEX 5000" || s == "FLEX-5000 Midi" || s == "FlexRadio Flex-5000" || s == "FlexRadio Flex-5000 MIDI") if (s.IndexOf("FLEX") >= 0 || s.IndexOf("Flex") >= 0) { Debug.WriteLine("Midi In Device Name: " + s); in_index = i; break; } } if (in_index < 0) { //MessageBox.Show("Error opening Midi In device"); return(false); } callback = new Midi.MidiInCallback(InCallback); int result = Midi.MidiInOpen(ref midi_in_handle, in_index, callback, 0, Midi.CALLBACK_FUNCTION); if (result != 0) { StringBuilder error_text = new StringBuilder(64); Midi.MidiInGetErrorText(result, error_text, 64); Debug.WriteLine("MidiInOpen Error: " + error_text); //MessageBox.Show("Error opening Midi In device"); return(false); } for (int i = 0; i < 3; i++) { result = Midi.AddSysExBuffer(midi_in_handle); if (result != 0) { StringBuilder error_text = new StringBuilder(64); Midi.MidiInGetErrorText(result, error_text, 64); Debug.WriteLine("AddSysExBuffer Error: " + error_text); //MessageBox.Show("Error adding Midi In device SysEx Buffer"); return(false); } } result = Midi.MidiInStart(midi_in_handle); if (result != 0) { StringBuilder error_text = new StringBuilder(64); Midi.MidiInGetErrorText(result, error_text, 64); Debug.WriteLine("MidiInStart Error: " + error_text); //MessageBox.Show("Error starting Midi In device"); return(false); } return(true); }