Esempio n. 1
0
    def lms(self):
        global wf_ech, wf_ref
        M = int(2 ** np.ceil(np.log2(self.M)))
        u = util.enframe(np.append(wf_ref, np.zeros(M)), 2 * M, M)
        d = util.enframe(wf_ech, M, 0)
        uf = nf.fft(u, 2 * M, 1)
        W = nf.fft(self.w, 2 * M)

        wf_ech = np.array([], np.complex128)

        for ii in range(0, u.shape[0]):
            mu_bar = (110 * np.exp(-(ii) / self.estep) + 1) * self.mu
            yfi = W * uf[ii, :]  # 1x2M
            yi = nf.ifft(yfi, 2 * M)  # 1x2M
            yi = yi[-M:]  # 1xM

            ei = d[ii, :] - yi  # 1xM
            efi = nf.fft(np.append(np.zeros(M), ei), 2 * M)  # 1x2M

            uefi = nf.ifft(np.conj(uf[ii, :]) * efi, 2 * M)
            uefi[-M:] = 0
            uei = nf.fft(uefi, 2 * M)

            W = W + 2 * mu_bar * uei
            wf_ech = np.append(wf_ech, ei)

        self.w = nf.ifft(W, 2 * M)
Esempio n. 2
0
    def enframe(self):
        global wf_ech, wf_ref
        self.ref_mat = util.enframe(wf_ref, self.framesize, self.overlap)
        self.ech_mat = util.enframe(wf_ech, self.framesize, self.overlap)

        def zeropad(x):
            return np.append(x, np.zeros(len(x)))

        def stickframe(x, y):
            return np.append(x, y)

        self.ref_mat = np.array(map(zeropad, self.ref_mat), np.complex128)
        temp = np.append(self.ech_mat[1:, :], np.array([np.zeros(self.framesize)], np.complex128), axis=0)
        self.ech_mat = np.array(map(stickframe, self.ech_mat, temp), np.complex128)
Esempio n. 3
0
def main():
    #awm = AWM('./testAudio/classical.wav', AwmOpt())
    awmOpt = AwmOpt()
    awmOpt.display()
    fs, au = util.audioread('./testAudio/classical.wav')
    frame = util.enframe(au, awmOpt.frameSize, awmOpt.overlap)
    M=512
    fmcltk = np.matrix(range(0, M+1), dtype=np.float64).reshape(-1, 1)
    fmcltc = np.multiply(awm.compExpo(8, 2*fmcltk+1), awm.compExpo(4*M, fmcltk))
    X = awm.fmclt2(frame, fmcltc)
    print(X.shape)
    print(X.dtype)
    yBar = np.zeros((1024, X.shape[1]), dtype=np.float64)
    for i in range(X.shape[1]):
        yBar[:, i] = awm.fimclt(X[:, i])
    print(yBar.shape)
    print(yBar.dtype)