fft_stft

 

Description

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

Syntax

int fft_stft( double * vSig, int iSigSize, double * vWindow, int iWinSize, double dSFeq, int iShiftPts, int iFftLen, int iSteps, double * vAmplitude, double * dScaleX, double * dScaleY )

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
vAmplitude
[input] the amplitude sequence to be returned
dScaleX
[output] the Scale of X
dScaleY
[output] the Scale of Y

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_sample()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
    {
        out_str("worksheet invalid");
        return;
    }
    
    Dataset dsSig(wks, 0);
    Dataset dsWin(wks, 1);
    
    vector vecSig, vecWin, vecResult;
    int iSigSize, iWinSize, iShift, iPadding;
    double dScaleX, dScaleY, dSFeq = 0.1;

    vecSig = dsSig;
    vecWin = dsWin;
    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(vecSig, iSigSize, vecWin, iWinSize, dSFeq, iShift, iPadding, iSteps, vecResult, &dScaleX, &dScaleY);
    if (ret != 0)
    {
        out_str("Fail call");
    }        
}

Remark

See Also

fft_stft_complex

header to Include

fft.h

Reference