/* SigLib Delay Example */ #include #include #define DELAY_LENGTH 5 #define SAMPLE_LENGTH 20 SLData_t RealSrcArray [] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, }; SLData_t ImagSrcArray [] = { 100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0, 110.0, 111.0, 112.0, 113.0, 114.0, 115.0, 116.0, 117.0, 118.0, 119.0, 120.0, 121.0, 122.0, 123.0, 124.0, 125.0, 126.0, 127.0, 128.0, 129.0, 130.0, 131.0, 132.0, 133.0, 134.0, 135.0, 136.0, 137.0, 138.0, 139.0, }; SLData_t *pRealDelayArray, *pImagDelayArray, *pRealDst, *pImagDst; void main (void) { SLArrayIndex_t i; SLArrayIndex_t DelayIndex; SLData_t pRealInput, pRealOutput; SLData_t pImagInput, pImagOutput; SLData_t *pRealSrc = RealSrcArray; SLData_t *pImagSrc = ImagSrcArray; pRealDelayArray = SUF_VectorArrayAllocate (DELAY_LENGTH); pImagDelayArray = SUF_VectorArrayAllocate (DELAY_LENGTH); pRealDst = SUF_VectorArrayAllocate (40); pImagDst = SUF_VectorArrayAllocate (40); /* Initialise the delay */ SIF_Delay (pRealDelayArray, /* Pointer to delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH); /* Delay filter length */ printf ("SDS_Delay\n"); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); pRealInput = *pRealSrc++; pRealOutput = SDS_Delay (pRealInput, pRealDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input = %1.1lf, Output = %1.1lf\n", pRealInput, pRealOutput); /* Initialise the delay */ SIF_Delay (pRealDelayArray, /* Pointer to delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH); /* Delay filter length */ SDA_Delay (pRealSrc, /* Pointer to source array */ pRealDst, /* Pointer to destination array */ pRealDelayArray, /* Pointer to delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH, /* Array length */ 20); /* Sample length */ printf ("\nSDA_Delay\n"); for (i = 0; i < 20; i++) { printf ("Input = %1.1lf, Output = %1.1lf\n", *pRealSrc++, *pRealDst++); } printf ("\nHit carriage return to continue . . .\n"); getchar (); pRealSrc = RealSrcArray; /* Reset real src array pointer */ /* Initialise the delay */ SIF_DelayComplex (pRealDelayArray, /* Pointer to real delay state array */ pImagDelayArray, /* Pointer to imaginary delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH); /* Delay filter length */ printf ("SDS_DelayComplex\n"); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); pRealInput = *pRealSrc++; pImagInput = *pImagSrc++; SDS_DelayComplex (pRealInput, pImagInput, &pRealOutput, &pImagOutput, pRealDelayArray, pImagDelayArray, &DelayIndex, DELAY_LENGTH); printf ("Input (Real) = %1.1lf, (Imag) = %1.1lf, Output (Real) = %1.1lf, (Imag) = %1.1lf\n", pRealInput, pImagInput, pRealOutput, pImagOutput); /* Initialise the delay */ SIF_DelayComplex (pRealDelayArray, /* Pointer to real delay state array */ pImagDelayArray, /* Pointer to imaginary delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH); /* Delay filter length */ SDA_DelayComplex (pRealSrc, /* Pointer to real source array */ pImagSrc, /* Pointer to imaginary source array */ pRealDst, /* Pointer to real destination array */ pImagDst, /* Pointer to imaginary destination array */ pRealDelayArray, /* Pointer to real delay state array */ pImagDelayArray, /* Pointer to imaginary delay state array */ &DelayIndex, /* Pointer to delay state index */ DELAY_LENGTH, /* Array length */ 20); /* Sample length */ printf ("\nSDA_DelayComplex\n"); for (i = 0; i < 20; i++) { printf ("Input = (Real) %1.1lf, (Imag) %1.1lf, Output = (Real) %1.1lf, (Imag) %1.1lf\n", *pRealSrc++, *pImagSrc++, *pRealDst++, *pImagDst++); } SUF_MemoryFree (pRealDelayArray); /* Free memory */ SUF_MemoryFree (pImagDelayArray); SUF_MemoryFree (pRealDst); SUF_MemoryFree (pImagDst); }