@staticmethod
    def pre_calculate(N, win, freq_min, freq_max, nqfreq):
        bins = int(win)/2
        #
        mel_min, mel_max = MFCCs.freq2mel(freq_min), MFCCs.freq2mel(freq_max)
        mel_centrs = np.arange(N+2) * (mel_max-mel_min) / (N+1) + mel_min
        bin_centrs = np.round(MFCCs.mel2freq(mel_centrs) / nqfreq * bins)
        #
        filters = np.zeros((N, bins))
        for i in xrange(N):
            st, ct, ed = bin_centrs[i:i+3]
            assert st < ct < ed
            #print st, ct, ed
            up = (np.arange(st,ct) - st) / (ct-st)
            down = (ed - np.arange(ct,ed)) / (ed-ct)
            filters[i,int(st):int(ct)] = up
            filters[i,int(ct):int(ed)] = down
        #
        dc = np.ones((N,N)) * np.arange(N,dtype=np.double)
        dcmt = np.pi * (0.5+dc) / N
        dcmt = (1.0 / np.sqrt(N/2.0)) * np.cos(dc.T * dcmt)
        dcmt[0] /= np.sqrt(2.0)
        #
        var = {
            'WL': win,
            'Triangles': filters,
            'DCTMatrix': dcmt
        }
        return type('variables', (object,), var)
dataset/ETHPy150Open dongying/dear/dear/analysis/mfcc.py/MFCCs.pre_calculate/original