spkit.stft_synthesis

spkit.stft_synthesis(mXt, pXt, winlen, overlap)

Short-Time Fourier Transform Synthesis Model

Synthesis of signal from Short-Time Fourier Transform

Parameters:
mXt: 2d-array
  • magnitude spectra of signal - 2d-array of shape (number of frames, int((nfft/2)+1))

pXt: 2d-array,
  • phase spectra of same size as mXt

winlen: int,
  • window length used while analysing

overlap: int,
  • overlap of windows used while analysing

Returns:
y1d-array
  • synthesized signal shape = (nFrames*overlap + winlen)

See also

dft_analysis

Discreet Fourier Transform - DFT

dft_synthesis

Inverse Discreet Fourier Transform - iDFT

stft_analysis

Short-Time Fourier Transform - STFT

stft_synthesis

Inverse Short-Time Fourier Transform - iSTFT

frft

Fractional Frourier Transform - FRFT

ifrft

Inverse Fractional Frourier Transform - iFRFT

sineModel_analysis

Sinasodal Model Decomposition

sineModel_synthesis

Sinasodal Model Synthesis

Notes

#TODO

Examples

    #sp.stft_analysis
    import numpy as np
    import matplotlib.pyplot as plt
    import spkit as sp
    x,fs,lead_names = sp.data.ecg_sample_12leads(sample=2)
    x = x[:int(fs*10),5]
    x = sp.filterDC_sGolay(x, window_length=fs//3+1)
    t = np.arange(len(x))/fs
    mXt, pXt = sp.stft_analysis(x,winlen=127, overlap=127//2)  # Analysis
    y = sp.stft_synthesis(mXt, pXt, winlen=127, overlap=127//2)   # Synthesis
    fig, (ax1, ax2,ax3) = plt.subplots(3, 1, gridspec_kw={'height_ratios': [1,2,1]},figsize=(10,6))
    ax1.plot(t,x)
    ax1.set_xlim([t[0],t[-1]])
    ax1.set_ylabel('x: input')
    ax1.grid()
    ax1.set_xticklabels('')
    ax2.imshow(mXt.T,aspect='auto',origin='lower',cmap='jet',extent=[t[0],t[-1],0,fs/2],interpolation='bilinear')
    ax2.set_ylabel('STFT(x)
Frequency (Hz)')
    ax2.set_xticklabels('')
    ax3.plot(t,y[:len(t)])
    ax3.set_xlim([t[0],t[-1]])
    ax3.set_ylabel('y: recon')
    ax3.grid()
    ax3.set_xlabel('Time (s)')
    fig.suptitle('Inverse STFT: Analysis and Synthesis')
    plt.tight_layout()
    plt.show()

Examples using spkit.stft_synthesis

Analysis and Synthesis Models

Analysis and Synthesis Models