private void buildCriticalBandFilterbank()
        {
            int             num             = (this.numberFftPoints >> 1) + 1;
            FrequencyWarper frequencyWarper = new FrequencyWarper();

            this.criticalBandFilter = new PLPFilter[this.numberFilters];
            if (this.numberFftPoints == 0)
            {
                string text = "Number of FFT points is zero";

                throw new IllegalArgumentException(text);
            }
            if (this.numberFilters < 1)
            {
                string text2 = new StringBuilder().append("Number of filters illegal: ").append(this.numberFilters).toString();

                throw new IllegalArgumentException(text2);
            }
            double[] array = new double[num];
            double   num2  = (double)(this.sampleRate / 2);

            for (int i = 0; i < num; i++)
            {
                array[i] = (double)i * num2 / (double)(num - 1);
            }
            double num3 = frequencyWarper.hertzToBark(this.minFreq);
            double num4 = frequencyWarper.hertzToBark(this.maxFreq);

            if (this.numberFilters < 1)
            {
                string text3 = new StringBuilder().append("Number of filters illegal: ").append(this.numberFilters).toString();

                throw new IllegalArgumentException(text3);
            }
            double num5 = (num4 - num3) / (double)(this.numberFilters + 1);

            for (int i = 0; i < this.numberFilters; i++)
            {
                double centerFreqInHz = frequencyWarper.barkToHertz(num3 + (double)i * num5);
                this.criticalBandFilter[i] = new PLPFilter(array, centerFreqInHz);
            }
        }
Exemplo n.º 2
0
        public PLPFilter(double[] DFTFrequenciesInHz, double centerFreqInHz)
        {
            FrequencyWarper frequencyWarper = new FrequencyWarper();

            this.numDFTPoints       = DFTFrequenciesInHz.Length;
            this.__centerFreqInHz   = centerFreqInHz;
            this.__centerFreqInBark = frequencyWarper.hertzToBark(centerFreqInHz);
            if (centerFreqInHz < DFTFrequenciesInHz[0] || centerFreqInHz > DFTFrequenciesInHz[this.numDFTPoints - 1])
            {
                string text = "Center frequency for PLP filter out of range";

                throw new IllegalArgumentException(text);
            }
            this.filterCoefficients = new double[this.numDFTPoints];
            for (int i = 0; i < this.numDFTPoints; i++)
            {
                double num = frequencyWarper.hertzToBark(DFTFrequenciesInHz[i]) - this.__centerFreqInBark;
                if (num < -2.5)
                {
                    this.filterCoefficients[i] = (double)0f;
                }
                else if (num <= -0.5)
                {
                    this.filterCoefficients[i] = Math.pow(10.0, num + 0.5);
                }
                else if (num <= 0.5)
                {
                    this.filterCoefficients[i] = (double)1f;
                }
                else if (num <= 1.3)
                {
                    this.filterCoefficients[i] = Math.pow(10.0, -2.5 * (num - 0.5));
                }
                else
                {
                    this.filterCoefficients[i] = (double)0f;
                }
            }
        }