| 1.12.4 Signal ProcessingSignal ProcessingOrigin C provides a collection of global functions and NAG functions for signal processing, ranging from smoothing noisy data to Fourier TransformFFT (FFT), Short-time FFTSTFT(STFT), Convolution and Correlation, FFT Filtering, and Wavelet analysis.
 The Origin C functions are under the Origin C help -> Origin C Reference -> Global Functions -> Signal Processing category.
 SmoothingThe ocmath_smooth function support 3 methods: median filter, Savitzky-Golay smoothing and adjacent averaging smoothing.
 vector vSmooth; // output
vSmooth.SetSize(vSource.GetSize());
//do Savitzky-Golay smoothing, Left=Right=7, quadratic
int nLeftpts = nRightpts = 3;
int nPolydeg = 2;
int nRet = ocmath_smooth(vSource.GetSize(), vSource, vSmooth, nLeftpts, SMOOTH_SG, 
	EDGEPAD_NONE, nRightpts, nPolydeg); FFTBefore using fft_* functions, you need to include fft_utils.h. 
 #include <fft_utils.h> FFTfft_real performs a discrete Fourier transform(FFT_FORWARD) or inverse Fourier transform(FFT_BACKWARD). 
 fft_real(vSig.GetSize(), vSig, FFT_FORWARD); // return 0 for no error Frequency Spectrumfft_one_side_spectrum is used to compute the one side spectrum of FFT Result.
 fft_one_side_spectrum(vSig.GetSize(), vSig); // return 0 for no error IFFTfft_real(vSig.GetSize(), vSig, FFT_BACKWARD); // return 0 for no error STFTThe stft_real function is used to perform a Short-Time-Fourier-Transform on 1d signal real data.
The stft_complex function is used to perform a Short-Time-Fourier-Transform on 1d signal complex data.
The following is an example for real data.
 int nWinSize = 4;
vector win(nWinSize);
get_window_data(RECTANGLE_WIN, nWinSize, win);
matrix stft;
double stime, sfreq;
vector sig = {0, 0, 0, 1, 1, 0, 0, 0};
stft_real(sig, win, 0.1, 1, 4, stft, stime, sfreq);
for (int ii = 0; ii < stft.GetNumRows(); ii++)
{
    for (int jj = 0; jj < stft.GetNumCols(); jj++)
        printf ("%f\t", stft[ii][jj]);
    printf ("\n");
}FFT FilteringOrigin C supports multiple filter types for performing FFT Filtering, including: low pass, high pass, band pass, band block, threshold, and low pass parabolic. For example:
 double dFc = 6.5;    
int iRet = fft_lowpass(vecSignal, dFc, &vecTime); Wavelet AnalysisIn Origin C, you can call a NAG function to do Wavelet analysis. To see all wavelet functions, go to the Origin C Help -> Origin C Reference -> Global Function -> NAG Functions -> Accessing NAG Functions Category and Help -> Wavelet category.
It is necessary to include the related header.
 #include <..\OriginLab\wavelet_utils.h> The following is an example of a real type, one-dimensional, continuous wavelet transform.
 int n = vX.GetSize();
int ns = vScales.GetSize();
matrix mCoefs(ns, n);
NagError fail;
nag_cwt_real(Nag_Morlet, 5, n, vX, ns, vScales, mCoefs, &fail); |