예제 #1
0
        private float[] calculateLogAverages(float[] freqs)
        {
            var       realWidth = this.formWidth / this.pixelsPerLine;
            const int shift     = 0;
            var       width     = realWidth + shift;// width used to ignore low frequences

            int samples  = freqs.Length;
            var averages = new WeightedAverage(realWidth);

            float logRatio = width / (float)Math.Log(samples, 2);

            for (int i = 1; i < samples; i++)
            {
                float freq = i;
                float amp  = freqs[i];

                float logFreq = (float)Math.Log(i, 2);

                int newIndex = (int)(logFreq * logRatio) - shift;
                if (newIndex >= 0)
                {
                    averages.Add(newIndex, amp);
                }
            }

            return(averages.GetAverges());
        }
예제 #2
0
        private static void findBand(WeightedAverage averages, float[] bandThresholds, float freq, float amp)
        {
            for (int n = 0; n < averages.Length; n++)
            {
                if (freq < bandThresholds[n])
                {
                    averages.Add(n, amp);
                    return;
                }
            }

            throw new Exception("Should have returned in for loop");
        }