Example #1
0
        public void Start()
        {
            int deviceId = GetDevice(_configuration.DeviceName);

            if (deviceId == -1)
            {
                _writeLog(_configuration.DeviceName + " not found!");
                //return;
            }

            var midiOut = new MidiOut(deviceId);

            this.registerers = this._configuration.Channels.Select((channel, currentChannelIndex) =>
            {
                try
                {
                    var r            = new HotKeyRegister(this._handle, currentChannelIndex, channel.HotKey.Modifiers, channel.HotKey.Key);
                    r.HotKeyPressed += (sender, eventArgs) =>
                    {
                        midiOut.SendBuffer(channel.Command);

                        var hotKey = channel.HotKey;
                        _writeLog(currentChannelIndex + " " + hotKey + " sent");
                    };

                    _writeLog(channel.HotKey + " registered");

                    return(r);
                }
                catch (Exception x)
                {
                    _writeLog(x.Message);
                }

                return(null);
            }).ToArray();
        }