Пример #1
0
        // ------------------- Output Ports ------------------
        public void AddOutputPort(OutputPort port)
        {
            if (OutputPorts.Contains(port))
                return;

            OutputPorts.Add(port);
        }
Пример #2
0
        public void RemoveOutputPort(OutputPort port)
        {
            if (!OutputPorts.Contains(port))
                return;

            OutputPorts.Remove(port);
            port.Dispose();
        }
Пример #3
0
        internal void FromXML(string xml)
        {
            var doc = new XmlDocument();
            doc.LoadXml(xml);
            string comPort = doc.SelectSingleNode("Configuration/GlobalConfiguration/InputName").InnerText;

            int midiDeviceId = -1;
            Int32.TryParse(doc.SelectSingleNode("Configuration/GlobalConfiguration/MidiDeviceID").InnerText, out midiDeviceId);

            int channelCount = 12;
            Int32.TryParse(doc.SelectSingleNode("Configuration/GlobalConfiguration/Channels").InnerText, out channelCount);

            int baudrate = 115200;
            Int32.TryParse(doc.SelectSingleNode("Configuration/GlobalConfiguration/Baudrate").InnerText, out baudrate);

            SetNumberOfChannels(channelCount);
            OpenSerialInput(comPort, baudrate, channelCount);

            OpenMidiOutput(midiDeviceId);

            // Load input config

            for (int i = 0; i < ChannelCount; i++)
            {
                var node = doc.SelectSingleNode("Configuration/InputConfiguration/Input[@Index='" + i + "']");
                if (node == null)
                    continue;
                ((InputChannel)Sources.InputChannels[i]).LoadXML(node.OuterXml);
            }

            var ports = Sources.GetOutputPorts();
            foreach (var port in ports)
                Sources.RemoveOutputPort(port);

            var nodes = doc.SelectNodes("Configuration/OutputConfiguration/Output");

            for (int i = 0; i < nodes.Count; i++)
            {
                var outputPort = new OutputPort();
                outputPort.LoadXML(nodes[i].OuterXml);
                Sources.AddOutputPort(outputPort);
            }
        }