Exemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     if (_image != null && _image.height == 8 && _image.width == 8)
     {
         _button.onClick.AddListener(ShowImage);
     }
     else
     {
         UnityEngine.Debug.LogError("Image is null or not a perfect 8x8 - cannot use");
         _button.onClick.AddListener(ShowRandomMapRtMidi);
     }
     foreach (var outputDeviceInfo in MidiDeviceManager.Default.OutputDevices)
     {
         if (outputDeviceInfo.Name == PUSH_OUT_NAME)
         {
             Debug.Log("Creating device!");
             _midiOutput = outputDeviceInfo.CreateDevice();
             _midiOutput.Open();
         }
     }
     //foreach (var inputDeviceInfo in MidiDeviceManager.Default.InputDevices)
     //{
     //    //Debug.Log("In Device " + inputDeviceInfo.Name);
     //}
 }
Exemplo n.º 2
0
        public void Init()
        {
            var slIn  = MidiDeviceManager.Default.InputDevices.SingleOrDefault(i => i.Name == "SL GRAND ");
            var slOut = MidiDeviceManager.Default.OutputDevices.SingleOrDefault(i => i.Name == "kipy_loopback1 ");

            if (slIn != null)
            {
                _inputDevice = slIn.CreateDevice();
                _inputDevice.ControlChange         += InputDevice_ControlChange;
                _inputDevice.NoteOn                += InputDevice_NoteOn;
                _inputDevice.NoteOff               += _inputDevice_NoteOff;
                _inputDevice.Nrpn                  += _inputDevice_Nrpn;
                _inputDevice.ChannelPressure       += _inputDevice_ChannelPressure;
                _inputDevice.PitchBend             += _inputDevice_PitchBend;
                _inputDevice.PolyphonicKeyPressure += _inputDevice_PolyphonicKeyPressure;
                _inputDevice.ProgramChange         += _inputDevice_ProgramChange;
                _inputDevice.Open();

                _outputDevice = slOut.CreateDevice();
                _outputDevice.Open();
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            KinectRegion.SetKinectRegion(this, kinectRegion);
            kinectRegion.KinectSensor = KinectSensor.GetDefault();
            // only one sensor is currently supported
            //kinectRegion.KinectSensor = KinectSensor.GetDefault();
            // set IsAvailableChanged event notifier
            kinectRegion.KinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            // open the sensor
            //kinectRegion.KinectSensor.Open();
            // set the status text
            this.StatusText = kinectRegion.KinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
                                                            : Properties.Resources.NoSensorStatusText;

            // open the reader for the body frames
            this.bodyFrameReader = kinectRegion.KinectSensor.BodyFrameSource.OpenReader();

            // set the BodyFramedArrived event notifier
            this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived;
            // initialize the gesture detection objects for our gestures
            this.gestureDetectorList = new List <GestureDetector>();

            // initialize the BodyViewer object for displaying tracked bodies in the UI
            kinectBodyView = new KinectBodyView(kinectRegion.KinectSensor);

            // initialize the MainWindow
            //this.InitializeComponent();

            // set our data context objects for display in UI
            this.DataContext = this;
            //this.kinectBodyViewbox.DataContext = this.kinectBodyView;


            int col0Row   = 0;
            int col1Row   = 0;
            int maxBodies = kinectRegion.KinectSensor.BodyFrameSource.BodyCount;



            a     = 40;
            chord = 0;

            /*GestureResultView result = new GestureResultView(0, false, false, 0.0f, false);
             *
             * GestureDetector detector = new GestureDetector(kinectRegion.KinectSensor, result);
             * this.gestureDetectorList.Add(detector);
             *
             * // split gesture results across the first two columns of the content grid
             * ContentControl contentControl = new ContentControl();
             * contentControl.Content = this.gestureDetectorList[0].GestureResultView;*/

            for (int i = 0; i < maxBodies; ++i)
            {
                GestureResultView result   = new GestureResultView(i, false, false, 0.0f, false);
                GestureDetector   detector = new GestureDetector(kinectRegion.KinectSensor, result);
                this.gestureDetectorList.Add(detector);

                // split gesture results across the first two columns of the content grid
                ContentControl contentControl = new ContentControl();
                contentControl.Content = this.gestureDetectorList[i].GestureResultView;

                if (i % 2 == 0)
                {
                    // Gesture results for bodies: 0, 2, 4
                    Grid.SetColumn(contentControl, 0);
                    Grid.SetRow(contentControl, col0Row);
                    ++col0Row;
                }
                else
                {
                    // Gesture results for bodies: 1, 3, 5
                    Grid.SetColumn(contentControl, 1);
                    Grid.SetRow(contentControl, col1Row);
                    ++col1Row;
                }

                //this.contentGrid.Children.Add(contentControl);
            }

            //this.ImageSource = this.notSeatedImage;
            Loaded += MainWindow_Loaded;

            dev = devInfo.CreateDevice();
            dev.Open();
        }