コード例 #1
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
 public static void DiscardAllBuffer(MIDIType Type)
 {
     if (Type == MIDIType.Serial)
         UtilitySerial.DiscardAllBuffer();
     else if (Type == MIDIType.MIDI_IN) midiIn.Reset();
     else if (Type == MIDIType.MIDI_OUT) midiOut.Reset();
 }
コード例 #2
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
        public static string[] GetMIDIDevices(MIDIType Type)
        {
            List<string> Devices = new List<string>();
            if (Type == MIDIType.Serial) return UtilitySerial.GetPortNames();
            else if (Type == MIDIType.MIDI_IN)
            {
                for (int i = 0; i < MidiInEx.NumberOfDevices; i++)
                    Devices.Add(MidiInEx.DeviceInfo(i).ProductName);

                if (Devices.Count == 0) return null;
            }
            else if (Type == MIDIType.MIDI_OUT)
            {
                for (int i = 0; i < MidiOutEx.NumberOfDevices; i++)
                    Devices.Add(MidiOutEx.DeviceInfo(i).ProductName);

                if (Devices.Count == 0) return null;
            }

            return Devices.ToArray();
        }
コード例 #3
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
 public static void Close(MIDIType Type)
 {
     if (Type == MIDIType.Serial) UtilitySerial.CloseCOM();
     else if (Type == MIDIType.MIDI_IN && midiIn != null) { midiIn.Stop(); midiIn.Close(); midiIn.Dispose(); midiIn = null; midiIn_Name = null; }
     else if (Type == MIDIType.MIDI_OUT && midiOut != null) { midiOut.Close(); midiOut.Dispose(); midiOut = null; midiOut_Name = null; }
 }
コード例 #4
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
 public static string PortName(MIDIType Type)
 {
     if (Type == MIDIType.Serial) return UtilitySerial.COM_Name;
     else if (Type == MIDIType.MIDI_IN) return midiIn_Name;
     else if (Type == MIDIType.MIDI_OUT) return midiOut_Name;
     return string.Empty;
 }
コード例 #5
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
        public static bool OpenMIDI(MIDIType Type, string Data)
        {
            //midiType = Type;
            try
            {
                if (Type == MIDIType.Serial)
                {
                    UtilitySerial.OpenCOM(Data);

                    if (UtilitySerial.IsOpen)
                    {
                        UtilitySerial.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
                        return true;
                    }
                }
                else if (Type == MIDIType.MIDI_IN)
                {
                    for (int i = 0; i < MidiInEx.NumberOfDevices; i++)
                        if (MidiInEx.DeviceInfo(i).ProductName == Data)
                        {
                            midiIn = new MidiInEx(i);
                            midiIn.ErrorReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_ErrorReceived);
                            midiIn.MessageReceived += new EventHandler<MidiInMessageEventArgs>(midiIn_MessageReceived);
                            midiIn.Start();
                            midiIn_Name = MidiInEx.DeviceInfo(i).ProductName;
                            return true;
                        }
                }
                else if (Type == MIDIType.MIDI_OUT)
                {
                    for (int i = 0; i < MidiOutEx.NumberOfDevices; i++)
                        if (MidiOutEx.DeviceInfo(i).ProductName == Data)
                        {
                            midiOut = new MidiOutEx(i);
                            midiOut_Name = MidiOutEx.DeviceInfo(i).ProductName;
                            return true;
                        }
                }
                return false;
            }
            catch (Exception exc)
            {
                return false;
            }
        }
コード例 #6
0
ファイル: UtilityMIDI.cs プロジェクト: Zoadian/md-config-tool
 public static bool IsOpen(MIDIType Type)
 {
     if (Type == MIDIType.Serial) return UtilitySerial.IsOpen;
     else if (Type == MIDIType.MIDI_IN) return midiIn != null;
     else if (Type == MIDIType.MIDI_OUT) return midiOut != null;
     return false;
 }