Esempio n. 1
0
        public void SetDataBlock(DataBlock db)
        {
            m_db = db;

             int lastValue=0;
             int run = 0;

             int average = m_db.GetAverage( 0 );

             textBox1.Text += string.Format("Average {0}\r\n", average);

             textBox1.Text += string.Format("Sample Rate {0}\r\n", db.m_sampleRate);

             textBox1.Text += string.Format("\r\nFreq from zeroes:\r\n", db.m_sampleRate);

             for (int i = 0; i < db.GetChannelLength(); i++)
             {
            int value = db.GetVoltage(0, i);;

            if (value > average && lastValue < average)
            {
               textBox1.Text += string.Format("{0} {1} {2}\r\n", i, run, 1.0/((float)run/(float)db.m_sampleRate) );
               run = 0;
            }

            run++;

            lastValue = value;
             }

             textBox1.Text += string.Format("\r\nFreq from self correlation:\r\n", db.m_sampleRate);

             double old = 10;
             for (int i = 0; i < db.GetChannelLength() / 2; i++)
             {
            double c = Correlate(db, i);
            if (c > old)
            {
               double waveLength = 2* (double)i / (double)db.m_sampleRate;
               textBox1.Text += string.Format("{0}\r\n", 1 / waveLength);
               break;
            }
            old = c;
             }
        }