void SongLoaded(SongData song, string songName, string songFile)
 {
     Dispatch.TriggerVolumeChanged(0.5f);
     rightHip.X = 0;
 }
        void SkeletonMoved(float time, Skeleton skel)
        {
            foreach (Joint joint in skel.Joints)
            {
                rightHand = skel.Joints[JointType.HandRight].Position;
                if (rightHip.X == 0)
                {
                    rightHip = skel.Joints[JointType.HipRight].Position;
                }
            }
            switch (seeking)
            {
            case "STILL":
            {
                if (stillFramesCount == 15)
                {
                    seeking = "START";
                }
                if (stillFramesCount < 15 && Math.Abs(prevOne.X - rightHand.X) < .08 && Math.Abs(prevOne.Y - rightHand.Y) < .08 && Math.Abs(prevTwo.X - rightHand.X) < .08 && Math.Abs(prevTwo.Y - rightHand.Y) < .08)
                {
                    stillFramesCount++;
                    break;
                }
                else if (stillFramesCount < 15)
                {
                    stillFramesCount = 0;
                }
                break;
            }

            case "START":
            {
                if (prevTwo.Y < (prevOne.Y - .01) && prevOne.Y < (rightHand.Y - .01))
                {
                    framesInFirstBeat++;
                    break;
                }
                if (framesInFirstBeat >= 2 && prevTwo.Y > (prevOne.Y + .01) && prevOne.Y > (rightHand.Y + .01))
                {
                    seeking = "MINIMUM";
                    break;
                }
                break;
            }

            case "MINIMUM":
            {
                if (prevTwo.Y < (prevOne.Y - threshold) && prevOne.Y < (rightHand.Y - threshold))
                {
                    xValues.Add(rightHand.X);
                    if (xValues.Count == 5)
                    {
                        xValues.RemoveAt(0);
                    }
                    if (xValues.Count == 4)
                    {
                        if (xValues.Min() == xValues.ElementAt(3))
                        {
                            volume = Math.Abs((rightHand.X - prevBeat) / .4) * 127;
                        }
                    }
                    prevBeat = rightHand.X;
                    seeking  = "MAXIMUM";
                    break;
                }
                break;
            }

            case "MAXIMUM":
            {
                if (prevTwo.Y > (prevOne.Y + threshold) && prevOne.Y > (rightHand.Y + threshold))
                {
                    seeking = "MINIMUM";
                    break;
                }
                break;
            }
            }
            if (Math.Abs(volume - newVolume) > 10)
            {
                if (volume < newVolume)
                {
                    if (newVolume > 0)
                    {
                        newVolume -= (2 * newVolume / 127);
                    }
                }
                if (volume > newVolume)
                {
                    if (newVolume < 127)
                    {
                        newVolume += (2 * (127 - newVolume) / 127);
                    }
                }
            }
            Dispatch.TriggerVolumeChanged(newVolume / 127);
            prevTwo = prevOne;
            prevOne = rightHand;
        }
 void SkeletonMoved(float time, Skeleton skel)
 {
     foreach (Joint joint in skel.Joints)
     {
         leftWrist = skel.Joints[JointType.WristLeft].Position;
         leftHip   = skel.Joints[JointType.HipLeft].Position;
         if (leftWrist.Y > leftHip.Y)
         {
             aboveHip   = true;
             outsideBox = false;
         }
         else
         {
             aboveHip     = false;
             count        = 0;
             startValue.Y = 0;
             startValue.X = 0;
             yAverage     = 0;
             xAverage     = 0;
         }
         if (joint.JointType == JointType.WristLeft)
         {
             if (count == 15)
             {
                 startValue.Y = yAverage;
                 startValue.X = xAverage;
                 count       += 1;
             }
             else if (count < 15)
             {
                 if (aboveHip == true && yAverage == 0 && xAverage == 0)
                 {
                     count   += 1;
                     yAverage = leftWrist.Y;
                     xAverage = leftWrist.X;
                 }
                 else if (aboveHip == true && yAverage != 0 && xAverage != 0)
                 {
                     if (yAverage - leftWrist.Y > -.1 && yAverage - leftWrist.Y < .1 && xAverage - leftWrist.X > -.1 && xAverage - leftWrist.X < .1)
                     {
                         yAverage = (yAverage + leftWrist.Y) / 2;
                         xAverage = (xAverage + leftWrist.X) / 2;
                         count   += 1;
                     }
                     else
                     {
                         yAverage = leftWrist.Y;
                         xAverage = leftWrist.X;
                         count    = 0;
                     }
                 }
             }
             else if (aboveHip == true && startValue.Y != 0 && startValue.X != 0 && tooClose == false)
             {
                 if ((startValue.X - leftWrist.X) < .1 && (startValue.X - leftWrist.X) > -.1 && Math.Abs(leftWrist.X - leftHip.X) < .3 && outsideBox == false) // if wrist is within the acceptable "box" of x-ranges
                 {
                     changeInYVal += (leftWrist.Y - prevYValue);
                     if (increaseToDecrease == 0 && leftWrist.Y - prevYValue > 0) //hand is moving up now
                     {
                         increaseToDecrease = 1;
                         changeVolume       = changeInYVal;
                     }
                     else if (increaseToDecrease == 1 && leftWrist.Y - prevYValue < 0) //hand is moving down now
                     {
                         increaseToDecrease = 0;
                         changeVolume       = changeInYVal;
                     }
                     else
                     {
                         changeInYVal += (leftWrist.Y - prevYValue);
                     }
                     prevYValue = leftWrist.Y;
                     if (changeInYVal - changeVolume > .1)
                     {
                         if (volume < 127)
                         {
                             volume += (5 * (127 - volume) / 127);
                         }
                     }
                     else if (changeInYVal - changeVolume < -.1)
                     {
                         if (volume > 0)
                         {
                             volume -= (5 * volume / 127);
                         }
                     }
                     int intVolume = (int)volume;
                     Dispatch.TriggerVolumeChanged(intVolume / 127f);
                 }
                 else
                 {
                     outsideBox = true;
                 }
             }
         }
     }
 }