示例#1
0
        public void SetOutputDevice(IOutputDevice outputDevice)
        {
            if (_outputDevice != null && _outputDevice.IsOpen)
            {
                _outputDevice.Close();
            }

            if (outputDevice != null)
            {
                _outputDevice        = outputDevice;
                _device.OutputDevice = _outputDevice;

                if (!_outputDevice.IsOpen)
                {
                    _outputDevice.Open();
                }
            }
            else
            {
                _outputDevice        = null;
                _device.OutputDevice = null;
            }

            OnPropertyChanged(nameof(OutputDevice));
        }
示例#2
0
        public MidiDevice()
        {
            timeOuts = new List <NoteTimeOut>();
#if UNITY_STANDALONE
            outputDevice = Midi.OutputDevice.InstalledDevices[0];
#elif UNITY_ANDROID
            outputDevice = new AndroidMidiDevice();
#elif UNITY_IOS
            outputDevice = new IOSMidiDevice();
#endif
            outputDevice.Open();
            outputDevice.SilenceAllNotes();
            System.Threading.Thread.Sleep(200); // fixes delay during initial playing, possibly due to midi device initialization
        }
        public Command8()
        {
            Console.WriteLine("Establishing MIDI Connection to Command|8...");
            SetUpFaders();
            SetUpEncoders();
            var devices    = Midi.Devices.DeviceManager.InputDevices;
            var outDevices = Midi.Devices.DeviceManager.OutputDevices;

            foreach (var inputDevice in devices)
            {
                if (inputDevice.Name.Contains("Command8") || inputDevice.Name.Contains("Command|8")) // For the differant driver versions.
                {
                    _midiDevice = inputDevice;
                    _midiDevice.ControlChange += MidiDevice_ControlChange;
                    _midiDevice.NoteOn        += MidiDevice_NoteOn;
                    Open();
                    break;
                }
            }
            foreach (var outDevice in outDevices)
            {
                if (outDevice.Name.Contains("Command8") || outDevice.Name.Contains("Command|8")) // For the differant driver versions.
                {
                    _midiOutDevice = outDevice;
                    _midiOutDevice.Open();
                    //WakeUp();
                    break;
                }
            }
            //Test();
            _screen = new Screen(_midiOutDevice);
            //Screen.ClearScreen();
            _screen.PrintText("V1.0.3", 0);// TODO: Fix the screen command.
            //Thread.Sleep(5000);
            ActivateLeds();
            FaderTest();
        }