Esempio n. 1
0
def idgt(X, hop_size, n_fft):
    """Compute the inverse DGT of real signal x with a gauss window."""
    assert len(X.shape) == 2
    assert np.mod(n_fft,
                  2) == 0, "The number of stft channels needs to be even"
    assert X.shape[0] == n_fft // 2 + 1
    g_synthesis = _synthesis_window(X, hop_size, n_fft)
    return idgtreal(X.astype(np.complex128), g_synthesis, hop_size, n_fft)[0]
Esempio n. 2
0
    def inverseOneSidedStft(self, signal, windowLength, hopSize):
        synthesis_window = {'name': 'gauss', 'M': windowLength}
        analysis_window = {
            'name': ('dual', synthesis_window['name']),
            'M': synthesis_window['M']
        }

        return ltfatpy.idgtreal(signal, analysis_window, hopSize,
                                windowLength)[0]
Esempio n. 3
0
 def idgt(self, X, hop_size=None, stft_channels=None):
     """Compute the inverse DGT of real signal x with a gauss window."""
     if hop_size is None:
         hop_size = self.hop_size
     if stft_channels is None:
         stft_channels = self.stft_channels
     assert (len(X.shape) == 2)
     assert (np.mod(stft_channels, 2) == 0), 'The number of stft channels needs to be even'
     assert (X.shape[0] == stft_channels // 2 + 1)
     g_synthesis = self._synthesis_window(X, hop_size, stft_channels)
     return idgtreal(X.astype(np.complex128), g_synthesis, hop_size, stft_channels)[0]
Esempio n. 4
0
def error_gabor(f, coeff, gs, a, M, th_method, Lambda,max =float('Inf')):
    # evaluate error from threshold of the real and imaginery coefficients

    L = len(f)
    c_thrshd = thresh(coeff.real, float(Lambda), th_method)[0] + 1j * thresh(coeff.imag, float(Lambda), th_method)[0]
    f_hat = idgtreal(c_thrshd, gs, a, M, L)[0]
    if Lambda<0 or Lambda>max:
        err = float('Inf')
    else:
        err = (np.linalg.norm(f_hat - f)**2)/L

    return err,f_hat
Esempio n. 5
0
 def backward(self, data):
     """
     Backward transform
     data -- input data (Numpy array)
     """
         
     if self.transform == 'dgtreal':
         out,_ = idgtreal(data, self.synthesis_window, \
                         self.time_step, self.num_freqs)
         return out
     elif self.transform == 'dgt':
         out,_ = idgt(data, self.synthesis_window, \
                           self.time_step, self.num_freqs)
         return out
     # elif test expression:
     else: 
         logging.warning("Unknown transform")
         return None