Ejemplo n.º 1
0
    //get data from microphone into audioclip
    float MicrophoneLevelMax()
    {
        float levelMax = 0;

        float[] waveData    = new float[_sampleWindow];
        int     micPosition = Microphone.GetPosition(null) - (_sampleWindow + 1); // null means the first microphone

        if (micPosition < 0)
        {
            return(0);
        }
        _clipRecord.GetData(waveData, micPosition);
        // Getting a peak on the last 128 samples
        Peaks.Clear();
        for (int i = 0; i < _sampleWindow; i++)
        {
            float wavePeak = waveData[i] * waveData[i];
            Peaks.Add(wavePeak);
            if (levelMax < wavePeak)
            {
                levelMax = wavePeak;
            }
        }

        return(MedianCalc.Median(Peaks, MedianPercent));

        return(levelMax);
    }
        public void Test_AverageByMedian()
        {
            ICalculate calculator = new MedianCalc();

            double expected = 8.0;

            double actual = Calculator.CalculateAverage(values, calculator);

            Assert.AreEqual(expected, actual, 0.000001);
        }