/// <summary> /// Opens a specified MIDI in device /// </summary> /// <param name="deviceNo">The device number</param> public MidiInEx(int deviceNo) { this.callback = new MidiInCallback(Callback); MmException.Try(MidiInOpen(out hMidiIn, deviceNo, this.callback, 0, CALLBACK_FUNCTION), "midiInOpen"); //MidiInPrepareHeader( //MidiInAddBuffer( }
public bool OpenMidiIn(int deviceID) { callback = new MidiInCallback(InCallback); int result = MidiInOpen(ref midi_in_handle, deviceID, callback, 0, CALLBACK_FUNCTION); if (result != 0) { StringBuilder error_text = new StringBuilder(64); 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 = AddSysExBuffer(midi_in_handle); if (result != 0) { StringBuilder error_text = new StringBuilder(64); MidiInGetErrorText(result, error_text, 64); Debug.WriteLine("AddSysExBuffer Error: " + error_text); //MessageBox.Show("Error adding Midi In device SysEx Buffer"); return(false); } } result = MidiInStart(midi_in_handle); if (result != 0) { StringBuilder error_text = new StringBuilder(64); MidiInGetErrorText(result, error_text, 64); Debug.WriteLine("MidiInStart Error: " + error_text); //MessageBox.Show("Error starting Midi In device"); return(false); } return(true); }
public static extern MmResult midiInOpen(out IntPtr hMidiIn, IntPtr uDeviceID, MidiInCallback callback, IntPtr dwInstance, int dwFlags);
public static extern int MidiInOpen(ref int lphMidiIn, int uDeviceID, MidiInCallback dwCallback, int dwInstance, int dwFlags);
public static extern int MidiInOpen(out IntPtr lphMidiIn, uint uDeviceID, MidiInCallback dwCallback, IntPtr dwInstance, MidiInOpenFlags dwFlags);