Beispiel #1
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);
        }
Beispiel #2
0
 public int FindOutputPort(string name)
 {
     return(OutputMidi.MapName(om, name));
 }