Exemple #1
0
        private int FindOutputName(OutputMidi[] om, OutputMidi o)
        {
            for (int i = 0; i < om.Length; i++)
            {
                if (om[i].Name == o.Name)
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemple #2
0
        public void GetMidiInfo()
        {
            for (int i = 0; i < InputDevice.DeviceCount; i++)
            {
                MidiInCaps caps = InputDevice.GetDeviceCapabilities(i);
                im[i] = new InputMidi(caps.name, i);
            }

            for (int i = 0; i < OutputDevice.DeviceCount; i++)
            {
                MidiOutCaps caps = OutputDevice.GetDeviceCapabilities(i);
                om[i] = new OutputMidi(caps.name, i);
            }
        }
Exemple #3
0
        public UDPMidiPort(int port, OutputMidi midiport)
        {
            UDPInPort = port;
            //OutputUdp2Midi = midiport;
            oml.Add(midiport);

            ipv4_listener = new UdpClient(UDPInPort, AddressFamily.InterNetwork);
            ipv6_listener = new UdpClient(UDPInPort, AddressFamily.InterNetworkV6);

            ipv4_thread = new Thread(new ThreadStart(ipv4_udpListener));
            ipv6_thread = new Thread(new ThreadStart(ipv6_udpListener));

            ipv4_thread.Start();
            ipv6_thread.Start();
        }
Exemple #4
0
        public void Add(int port, OutputMidi midiport)
        {
            UDPMidiPort u = list.Find(x => x.UDPInPort == port);

            if (u != null)
            {
                if (u.oml.Find(x => x.Name == midiport.Name) == null)
                {
                    u.oml.Add(midiport);
                }
            }
            else
            {
                list.Add(new UDPMidiPort(port, midiport));
            }
        }
Exemple #5
0
        public bool ParseFile(string file)
        {
            if (!File.Exists(file))
            {
                Console.WriteLine("Couldn't find input file " + file);
                return(false);
            }

            using (StreamReader fs = File.OpenText(file))
            {
                while (fs.Peek() >= 0)
                {
                    string line = fs.ReadLine();
                    int    n    = line.IndexOf(',');
                    if (n > 0)
                    {
                        string leftside  = line.Substring(0, n);
                        string rightside = line.Substring(n + 1);

                        if (leftside[0] == '#')
                        {
                            int OutPort = OutputMidi.MapName(om, rightside);
                            if (OutPort == -1 || OutPort >= om.Length)
                            {
                                Console.Write("Outport for UDP " + OutPort.ToString() + " is invalid for ");
                            }
                            else
                            {
                                int UdpPort;
                                if (!int.TryParse(leftside.Substring(1), out UdpPort))
                                {
                                    Console.WriteLine("Unable to convert destination port " + leftside.Substring(1));
                                }
                                else
                                {
                                    if (UdpPort > MAXMIDIPORTS)
                                    {
                                        AddRoute(UdpPort, OutPort);
                                    }
                                    else
                                    {
                                        Console.WriteLine("UDP Port must be greater than {0}", MAXMIDIPORTS);
                                    }
                                };
                            }
                        }
                        else
                        {
                            int InPort  = InputMidi.MapName(im, leftside);
                            int OutPort = OutputMidi.MapName(om, rightside);

                            if (InPort == -1 || InPort >= im.Length || OutPort == -1 || OutPort >= om.Length)
                            {
                                Console.Write("Port range, " + InPort.ToString() + " to " + OutPort.ToString() + " is invalid for ");
                            }
                            else
                            {
                                Console.Write("Port range, " + InPort.ToString() + " to " + OutPort.ToString() + " router for ");
                                AddRoute(InPort, OutPort);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Exemple #6
0
 public int FindOutputPort(string name)
 {
     return(OutputMidi.MapName(om, name));
 }
Exemple #7
0
 public void DisplayOutputMidiPorts()
 {
     OutputMidi.PrintMidiList(om);
     Console.WriteLine();
 }