示例#1
0
    /**
     * Designs the Mel filter and creates triangular spectrum.
     *
     * @param filterNum which filter in a sequence it is
     * @param melFilterWidth filter width in Mel scale (eg. 200)
     * @param N filter spectrum size (must be the same as filtered spectrum)
     */
    void MelFilter::createFilter(std::size_t filterNum,
                                 FrequencyType melFilterWidth, std::size_t N)
    {
        // calculate frequencies in Mel scale
        FrequencyType melMinFreq = filterNum * melFilterWidth / 2.0;
        FrequencyType melCenterFreq = melMinFreq + melFilterWidth / 2.0;
        FrequencyType melMaxFreq = melMinFreq + melFilterWidth;

        // convert frequencies to linear scale
        FrequencyType minFreq = melToLinear(melMinFreq);
        FrequencyType centerFreq = melToLinear(melCenterFreq);
        FrequencyType maxFreq = melToLinear(melMaxFreq);

        // generate filter spectrum in linear scale
        generateFilterSpectrum(minFreq, centerFreq, maxFreq, N);
    }
示例#2
0
    /**
     * Designs the Mel filter and creates triangular spectrum.
     *
     * @param filterNum which filter in a sequence it is?
     * @param melFilterWidth filter width in Mel scale (eg. 200)
     * @param N filter spectrum size (must be the same as filtered spectrum)
     */
    void MelFilter::createFilter(unsigned short filterNum,
                                 unsigned short melFilterWidth, unsigned int N)
    {
        // calculating frequencies in Mel scale
        double melMinFreq = filterNum * melFilterWidth / 2.0;
        double melCenterFreq = melMinFreq + melFilterWidth / 2.0;
        double melMaxFreq = melMinFreq + melFilterWidth;

        // converting them to linear
        double minFreq = melToLinear(melMinFreq);
        double centerFreq = melToLinear(melCenterFreq);
        double maxFreq = melToLinear(melMaxFreq);

        // generating spectrum in linear scale
        generateFilterSpectrum(minFreq, centerFreq, maxFreq, N);
    }