dft_freq_fig1.c Calculating the data for plotting Figure 1 of Section Indexation and shifting of discrete Fourier transform spectrum samples . The program calculates the spectrum amplitude of the $|S(k)|$ signal $s(n) = \exp \left( j \cdot 2\pi \cdot n \cdot \frac{f_0}{F_\textrm{s}} \right),$ where $f_0 = -20$ Hz, $F_\textrm{s} = 120$ Hz, $n = 0\ldots N-1$, $N = 30$. The calculated amplitude spectrum $|S(k)|$ is saved in dat/dft_freq_fig1.txt for plotting the chart. #include #include #include #include "dspl.h"/* DFT size */#define N 30int main(){    HINSTANCE hDSPL;        /* dspl handle              */    void* pdspl = NULL;     /* dspl object pointer      */    double sR[N];           /* input signal real part   */    double sI[N];           /* input signal image part  */    double SR[N];           /* DFT real part            */    double SI[N];           /* DFT image part           */    double S[N];            /* Spectrum magnitude       */    double k[N];            /* indexes                  */          double f0 = -20;        /* signal frequency (Hz)    */      double Fs = 120;        /* Sample rate (Hz)         */        int n;    /* Load dspl.dll */    hDSPL = dspl_load();    if(!hDSPL)    {        printf("dspl.dll loading ERROR!\n");        return 0;    }    /* DSPL object create */    dspl_obj_create(&pdspl);    /* s(n) = exp(j*2*pi*f0*(0:N-1)/Fs) */    for(n = 0; n < N; n++)    {        sR[n] = cos(M_2PI * f0 * (double)n / Fs);        sI[n] = sin(M_2PI * f0 * (double)n / Fs);    }    /* DFT calculation */    dspl_dft(sR, sI, N, SR, SI);    /* Spectrum magnitude and indexes calculation */    for(n = 0; n < N; n++)    {        S[n] = sqrt(SR[n]*SR[n] + SI[n]*SI[n]);        k[n] = (double)n;    }    /* Save spectrum magnitude to dat/dft_freq_fig1.txt file */    dspl_writetxt(k,S,N,"dat/dft_freq_fig1.txt");    /* destroy DSPL object */    dspl_obj_free(&pdspl);                    /* clear dspl handle */     FreeLibrary(hDSPL);        return 0;} Generated on Sat Mar 11 2017 12:37:50 for DSPL - Digital signal processing library by   1.8.13