Return To Numerix Home Page   Numerix Corporate Details  

SigLib Example Program

  SigLib Library   Digital Filter Plus

Witing programs using the SigLib DSP library is very easy, the API is designed to be as intuitive as possible. The complete function list and can be viewed on-line. All of the SigLib functions are split into logical groups with the following function prefixes :

SIF_ - SigLib initialisation function
SDA_ - SigLib data array oriented operation
SDS_ - SigLib data sample oriented operation
SCV_ - SigLib complex vector sample oriented operation
SMX_ - SigLib multi-dimensional matrix array oriented operation
SIM_ - SigLib image processing and coding operation
SUF_ - SigLib utility function

As an example, the following show how to use the FIR filter functions :

SIF_Fir - Initialise the FIR filter functionality
SDS_Fir - Perform the FIR filter on the sample oriented data stream
SDA_Fir - Perform the FIR filter on the array oriented data stream

The following is an example program that performs windowing, FFT and square magnitude power calculation on the input data set :

/* SigLib FFT and Hanning window test program */

/* Include files */

#include <math.h>
#include <stdlib.h>
#include <siglib.h>

/* Define constants */

#define	FFT_SIZE            512
#define	LOG_FFT_SIZE        9
#define	WINDOW_SIZE         FFT_SIZE

#define SIGNAL_MAGNITUDE    1.0
#define SIGNAL_FREQUENCY    0.019	/* Normalised to 1.0 Hz */

/* Define global variables */

SFLOAT	*pRealData, *pImagData, *pWindowCoeffs, *pResultsData, *pFFTCoeffs;

SFLOAT	SinePhase;

void main (void)
    SFIX	SigLibErrorCode;

    pRealData = SUF_VectorArrayAllocate (FFT_SIZE);\       /* Allocate data arrays */
    pImagData = SUF_VectorArrayAllocate (FFT_SIZE);
    pFFTCoeffs = SUF_FftCoefficientAllocate (FFT_SIZE);
    pResultsData = SUF_VectorArrayAllocate (FFT_SIZE);     /* RMS result data array */
    pWindowCoeffs = SUF_VectorArrayAllocate (WINDOW_SIZE); /* Window data array */

    SigLibErrorCode = SIF_Fft (pFFTCoeffs, SIGLIB_NULL_SFIX_PTR, FFT_SIZE); /* Init. FFT */
    if (SigLibErrorCode != SIGLIB_NO_ERROR)
        SUF_Halt;                                          /* Halt on error */

    SinePhase = SIGLIB_ZERO;                               /* Generate signal for FFT input */
                         SIGLIB_NULL_SFLOAT_PTR, FFT_SIZE);

    SIF_Window (pWindowCoeffs, SIGLIB_HANNING, FFT_SIZE);  /* Generate Hanning window table */
    SDA_Window (pRealData, pRealData, pWindowCoeffs, WINDOW_SIZE);  /* Apply window to data */

                                                           /* Perform FFT */
    SDA_Rfft (pRealData, pImagData, pFFTCoeffs, SIGLIB_NULL_SFIX_PTR, FFT_SIZE, LOG_FFT_SIZE);
                                                           /* Scale output for display */
    SDA_Divide (pRealData, pRealData, ((SFLOAT)FFT_SIZE), FFT_SIZE);
    SDA_Divide (pImagData, pImagData, ((SFLOAT)FFT_SIZE), FFT_SIZE);
    SDA_RmsPower (pRealData, pImagData, pResultsData, FFT_SIZE);   /* Calc real power */

    SUF_MemoryFree (pRealData);                            /* Free memory */
    SUF_MemoryFree (pImagData);
    SUF_MemoryFree (pResultsData);
    SUF_MemoryFree (pWindowCoeffs);

One of the great things about SigLib is that this program can be re-compiled and used on any of the supported processors without modification. SigLib is also supported by over 80 example programs showing how to use all of the functionality of the library and it is supplied with full documentation.

Home Page | SigLib™ DSP Library | DFPlus™ Filter Designer

Return To Numerix Home Page Top Of Page

If you have any comments or questions please email Numerix :
Copyright 2018, Sigma Numerix Ltd.. Permission is granted to create WWW pointers to this document. All other rights reserved. All trademarks acknowledged.