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); }
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); } }
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(); }
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)); } }
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); }
public int FindOutputPort(string name) { return(OutputMidi.MapName(om, name)); }
public void DisplayOutputMidiPorts() { OutputMidi.PrintMidiList(om); Console.WriteLine(); }