예제 #1
0
        private static void UpdateDevices()
        {
            int count = MidiInput.Count;

            CloseAllConnections();

            int index = 0;

            foreach (string dev in MidiInput.GetDeviceList())
            {
                if (Maps.ContainsKey(dev))
                {
                    MidiMap map      = Maps[dev];
                    int     outIndex = MidiOutput.GetDeviceIdByName(dev);
                    map.ConnectDevice(index, outIndex);
                }
                else
                {
                    // Can't find map so create a new default map
                    MidiMap map = new MidiMap();
                    map.Name  = dev;
                    map.Dirty = true;
                    int outIndex = MidiOutput.GetDeviceIdByName(dev);
                    map.ConnectDevice(index, outIndex);
                    map.UpdateMapLinks();
                    Maps[map.Name] = map;
                }
                index++;
            }
            MidiSetup.UpdateDeviceList();

            MidiInputCount = count;
        }
예제 #2
0
        public static void LoadMap(string filename, bool update)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(MidiMap));
            FileStream    fs         = new FileStream(filename, FileMode.Open);

            MidiMap map = (MidiMap)serializer.Deserialize(fs);

            Maps[map.Name] = map;
            map.Dirty      = true;

            fs.Close();
            map.UpdateMapLinks();

            if (update)
            {
                UpdateDevices();
            }
        }
        private static void UpdateDevices()
        {
            var count = MidiInput.Count;
            CloseAllConnections();

            var index = 0;
            foreach (var dev in MidiInput.GetDeviceList())
            {
                if (Maps.ContainsKey(dev))
                {
                    var map = Maps[dev];
                    var outIndex = MidiOutput.GetDeviceIdByName(dev);
                    map.ConnectDevice(index, outIndex);
                }
                else
                {
                    // Can't find map so create a new default map
                    var map = new MidiMap();
                    map.Name = dev;
                    map.Dirty = true;
                    var outIndex = MidiOutput.GetDeviceIdByName(dev);
                    map.ConnectDevice(index, outIndex);
                    map.UpdateMapLinks();
                    Maps[map.Name] = map;
                }
                index++;
            }
            MidiSetup.UpdateDeviceList();

            MidiInputCount = count;
        }