private void SubscribeToDevices()
 {
     foreach (var command in _commandControlMappings)
     {
         var config = (MidiConfiguration)command.hardwareConfiguration;
         MidiIn._StartListening(MidiIn.GetDeviceByName(config.MidiDevice)?.Id);
     }
 }
        public override void AddCommand(CommandControlMappingElement command)
        {
            var config = (MidiConfiguration)command.hardwareConfiguration;

            MidiIn._StartListening(MidiIn.GetDeviceByName(config.MidiDevice)?.Id);

            _commandControlMappings.Add(command);
            SaveSettings(SAVEKEY);
        }
        public override void ModifyCommandAt(int index, CommandControlMappingElement newCommand)
        {
            if (_commandControlMappings.Count < index)
            {
                return;
            }

            var config = (MidiConfiguration)newCommand.hardwareConfiguration;

            MidiIn._StartListening(MidiIn.GetDeviceByName(config.MidiDevice)?.Id);

            _commandControlMappings[index] = newCommand;
            SaveSettings(SAVEKEY);
        }
        public MidiAppBinding(DeviceCollectionViewModel deviceCollectionViewModel,
                              IAudioDeviceManager audioDeviceManager) : base(deviceCollectionViewModel, audioDeviceManager)
        {
            Current = this;

            MidiIn.AddGeneralCallback(MidiCallback);

            LoadSettings(SAVEKEY);

            _deviceMapping = new ConcurrentDictionary <string, string>();

            foreach (var device in MidiIn.GetAllDevices())
            {
                _deviceMapping[device.Id] = device.Name;
            }

            SubscribeToDevices();
        }
        private string GetMidiDeviceById(string id)
        {
            if (_deviceMapping.ContainsKey(id))
            {
                return(_deviceMapping[id]);
            }

            foreach (var device in MidiIn.GetAllDevices())
            {
                if (!_deviceMapping.ContainsKey(device.Id))
                {
                    _deviceMapping[device.Id] = device.Name;
                    if (device.Id == id)
                    {
                        return(device.Name);
                    }
                }
            }

            return("");
        }
Exemplo n.º 6
0
 public void RemoveControlChangeCallback(Action <MidiControlChangeMessage> callback, byte channel = 255,
                                         byte controller = 255)
 {
     MidiIn.RemoveControlChangeCallback(Id, callback, channel, controller);
 }