Exemplo n.º 1
0
        public FaderPort()
        {
            _inputDevice  = InputDevice.GetByName("FaderPort");
            _outputDevice = OutputDevice.GetByName("FaderPort");

            if (_inputDevice == null)
            {
                throw new InvalidOperationException("Unable to connect to FaderPort input device.");
            }

            if (_outputDevice == null)
            {
                throw new InvalidOperationException("Unable to connect to FaderPort output device.");
            }

            _inputDevice.EventReceived += OnInputEvent;
            _inputDevice.StartEventsListening();
            _outputDevice.PrepareForEventsSending();

            var nativeEvent = new NoteOnEvent((SevenBitNumber)0, (SevenBitNumber)0x64)
            {
                Channel = (FourBitNumber)1
            };

            Console.WriteLine("Switching FaderPort to native mode.");
            _outputDevice.SendEvent(nativeEvent);
            ClearAllLights();

            _cts           = new CancellationTokenSource();
            _blinkerThread = new Thread(BlinkerMain);
            _blinkerThread.Start();
        }