/// <summary> /// Create a gesture detector that changes the volume when the hand is rotated along the Z axis /// </summary> public static ContinuousGestureDetector RotateHandChangeVolumeGesture() { return(new ContinuousGestureDetector( // Only allow rotation if hand is closed and visible for a bit hand => !hand.IsOpen && hand.TimeVisible >= 500 * 1000, // Track hand roll (angle along Z axis) in radians, from 0 to 2PI delegate(HandStats hand) { if (hand.Roll >= 0) { return hand.Roll; } // Transform the -PI to 0 space to be from PI to 2 * PI return (float)(Math.PI * 2 + hand.Roll); }, // Trigger every 0.35 radians / 20 degrees 0.35f, // Increase volume if rotating clockwise delegate(bool isPositive) { if (isPositive) { VolumeUtil.VolumeUp(); } else { VolumeUtil.VolumeDown(); } }) { DirectionDebounceTime = 500 * 1000 }); }
public void VolumeConversion() { for (double x = 0d; x < 1000d; x += 0.00123d) { double result = VolumeUtil.DecibelToLinear(VolumeUtil.LinearToDecibel(x)); Debug.WriteLine("{0}: L2D={1} -> {2}", x, VolumeUtil.LinearToDecibel(x), result); Assert.AreEqual(x, result, 0.000001d); } }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null || !(value is double)) { return(double.NaN); } // decibel to linear return(VolumeUtil.DecibelToLinear((double)value)); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null || !(value is double)) { return(double.NaN); } // linear to decibel return(VolumeUtil.LinearToDecibel((double)value)); }
/// <summary> /// Create a gesture detector that changes the volume when the hand is moved left and right (along the X axis) /// </summary> public static ContinuousGestureDetector MoveHandXChangeVolumeGesture() { return(new ContinuousGestureDetector( // Only acknowledge hand if it's visible for a bit first hand => hand.TimeVisible >= 500 * 1000, // Track lateral hand movement along long axis of Leap hand => hand.PalmPosition.x, // Trigger every 30 millimeters 30, // Increase volume if moving right delegate(bool isPositive) { if (isPositive) { VolumeUtil.VolumeUp(); } else { VolumeUtil.VolumeDown(); } })); }