initialize() public static method

public static initialize ( ) : void
return void
Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;

            this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);

            // Print out all the possible input devices to console. Mostly for debugging.
            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                Console.WriteLine("Device {0}: {1}, {2} channels",
                                  waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }

            // Instantiate a waveIn device and start recording.
            waveIn = new WaveIn();
            waveIn.BufferMilliseconds = 47 * buffersize / 2048;
            waveIn.DeviceNumber       = 0;
            waveIn.WaveFormat         = new WaveFormat(44100, 32, 1);
            waveIn.DataAvailable     += waveIn_DataAvailable;

            try
            {
                waveIn.StartRecording();
            }
            catch (NAudio.MmException e)
            {
                Console.WriteLine(e.ToString() + "\nPlug in a microphone!");
            }

            history         = new List <List <int> >();
            inverse_history = new List <List <int> >();
            pointHist       = new PointCollection();

            bin        = new int[buffersize * 2];
            sampledata = new float[buffersize * 2];
            priori     = new double[buffersize * 2];


            //Initializing all the global variables to base values for 1 speaker configuration.
            channelLabel    = new int[1];
            channelLabel[0] = 1;
            velocity        = new int[1];
            velocity[0]     = 0;

            prev_displacement    = new int[1];
            prev_displacement[0] = 0;

            instant_displacement    = new int[1];
            instant_displacement[0] = 0;

            towards_displacement    = new int[1];
            towards_displacement[0] = 1;


            displacement    = new int[1];
            displacement[0] = 0;

            for (int i = 0; i < buffersize * 2; i++)
            {
                bin[i]        = i;
                sampledata[i] = 0;
                priori[i]     = 0;
            }

            // Kalman filter related stuff.
            filter = new VDKalman(2);
            filter.initialize(1, .1, 1, 0);

            // To prevent problems with empty lists, we assume 1 channel to start.
            history.Add(new List <int> {
                0
            });
            inverse_history.Add(new List <int> {
                0
            });

            // Load up the classifier model file.
            WekaHelper.initialize();
        }