2014年12月10日 星期三

1. Simplify Kinect code based on version 1.8 --- Audio event

Ref : AudioBasic-WPF
This example demonstrates the audio sensor application by 6 steps.

// 1. Add Ref Kinect 1.8
// 2. Add namespace
using Microsoft.Kinect;

namespace AudioAngleEx1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 3. Create Sensor object
            KinectSensor Sensor = KinectSensor.KinectSensors[0];
            // 4. Add event method
            Sensor.AudioSource.BeamAngleChanged += AudioSource_BeamAngleChanged;
            // 5. Start Sensor
            Sensor.Start();
            // 6. Start Microphone
            Sensor.AudioSource.Start();
            Console.WriteLine("Press 'Enter' then stop.");
            Console.ReadLine();

        }

        static void AudioSource_BeamAngleChanged(object sender, BeamAngleChangedEventArgs e)
        {
            Console.WriteLine("BeamAngle = {0} ", e.Angle);
        }
    }
}