2.1.22.2.1.44 fft_stft_complex


Description

Get a amplitude sequence from a signal sequence using Short-Time-Fourier-Transform method.

Syntax

int fft_stft_complex( d_complex * vSig, int iSigSize, double * vWindow, int iWinSize, double dSFeq, int iShiftPts, int iFftLen, int iSteps, d_complex * pOutComplex, double * pAmp, double * dScaleTime, double * dScaleFreq )

Parameters

vSig
[input] the input source signal sequence
iSigSize
[input] size of signal sequence
vWindow
[input] window data sequence to be applied
iWinSize
[input] size of window data
dSFeq
[input] the interval of time
iShiftPts
[input] shift of the window per step
iFftLen
[input] FFT Length, should not less than window size
iSteps
[input] number of steps
pOutComplex
[output] the complex output to be returned, size should be iSteps*iFftLen
pAmp
[output] Amplitude of result matrix, size should be iSteps*iFftLen
dScaleTime
[output] the maximum time of the STFT spectrum, it's also the XMax of matSTFT
dScaleFreq
[output] the maximum frequency of the STFT spectrum, it's also the YMax of matSTFT

Return

Returns 0 for success or error codes for failure.

Examples

EX1

//Assume in the current worksheet, the first is signal sequence, the second is the 
//window data to be applied.

#include <..\originlab\fft.h>
void fft_stft_complex_sample()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
    {
        out_str("worksheet invalid");
        return;
    }
    
    Dataset dsReal(wks, 0);
    Dataset dsImg(wks, 1);
    Dataset dsWin(wks, 2);
    
    vector<complex> vecSig;    
    vector<complex> vecResult;    
    vector vecReal, vecImg, vecWin;
    int iSigSize, iWinSize, iShift, iPadding;
    double dScaleX, dScaleY, dSFeq = 0.1;

    vecReal = dsReal;
    vecImg = dsImg;
    vecWin = dsWin;
    vecSig.MakeComplex(vecReal, vecImg);
    
    iSigSize = vecSig.GetSize();
    iWinSize = vecWin.GetSize();
    iShift = 5;                  //specify a number just as you wish
    iPadding = 10;
    int iSteps = iSigSize/iShift;
    vecResult.SetSize(iSteps * (iWinSize+iPadding));

    int ret = fft_stft_complex(vecSig, iSigSize, vecWin, iWinSize, dSFeq, iShift, iPadding, iSteps, vecResult, NULL, &dScaleX, &dScaleY);
    if (ret != 0)
    {
        out_str("Fail call");
    }
}

Remark

See Also

fft_stft

Header to Include

fft.h

Reference