Ejemplo n.º 1
0
        /// <summary>
        /// Sets the playing mode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetMode(object sender, RoutedEventArgs e)
        {
            if (AdvancedMode.IsChecked.GetValueOrDefault())
            {
                playingMode = ADVANCED_MODE;

                for (int i = 1; i < PartitionRadio.Children.Count; i++)
                {
                    PartitionRadio.Children[i].IsEnabled = true;
                }
                instruments[0] = new Instrument("instr0");
            }
            else
            {
                playingMode = DEMO_MODE;

                PartitionManager.SetPartitionType(PartitionType.Single);
                onePartition.IsChecked = true;

                for (int i = 1; i < PartitionRadio.Children.Count; i++)
                {
                    PartitionRadio.Children[i].IsEnabled = false;
                }
                instruments[0] = new DemoInstrument("instr0");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends OSC messages if applicable
        /// </summary>
        /// <returns>The color the background should display (for user feedback)</returns>
        private bool SendInstrumentData(Body body)
        {
            // Send joint data to animators, write to a file
            if (body.HandLeftState == body.HandRightState && body.HandLeftState == HandState.Open)
            {
                //SendJointData(body, true);
            }

            CameraSpacePoint spineMidPos = body.Joints[JointType.SpineMid].Position;
            CameraSpacePoint lHandPos    = body.Joints[JointType.HandLeft].Position;
            CameraSpacePoint rHandPos    = body.Joints[JointType.HandRight].Position;

            // trigger start if both left and right hand are open
            bool triggerStart = body.HandLeftState == body.HandRightState && body.HandLeftState == HandState.Open;
            // trigger end if both left and right hand are closed and below the Kinect
            bool triggerEnd = body.HandLeftState == body.HandRightState && body.HandLeftState == HandState.Closed && lHandPos.Y < 0 && rHandPos.Y < 0;

            int partition = PartitionManager.GetPartition(spineMidPos);

            if (body.HandLeftState == HandState.Lasso)
            {
                // Send volume as a value between 0 and 1, only when thumbs up
                //sliders[instruments[partition] + "/volume"].Send(lHandPos.Y);
            }

            // Ask the instrument if it wants to play
            Instrument instrument = instruments[partition];

            Console.WriteLine(instrument.ToString());
            if (instrument.ToString() == "MidiPad")
            {
                MidiPad pad = (MidiPad)instruments[partition];

                return(pad.CheckAndPlayNote(body));
            }
            else if (playingMode == DEMO_MODE)
            {
                DemoInstrument demoInstr = (DemoInstrument)instruments[partition];

                return(demoInstr.CheckAndPlayNoteD(body));
            }
            else
            {
                return(instrument.CheckAndPlayNote(body));
            }
        }