sdr

Capsim Block Documentation

Short Description

Compute signal to distortion ratio

Top
Parameters
Num Description Type Name Default Value
0 Number of points to collect int npts
1 Number of points to skip int skip
2 File to store SDR results file sdrRes
3 Window: 0=Rect., 1=Hamming int windFlag 0
Top
Result Variables (TCL)
Num Type Name Description
0 float BlockName_sdr The Signal to Distortion(Noise) Ratio
Top
States
Num Type Name Initial Value Description
0 int ibufs
1 int obufs
2 float* xpts
3 float* ypts
4 float* spect
5 cap_fft_cpx* cxinBuff
6 cap_fft_cpx* cxoutBuff
7 cap_fft_cfg cfg
8 int count 0
9 int total_count 0
10 int fftl
11 int fftexp
Top

Declarations


 

	int samples;
    	int i,j;
	float tmp;
	float wind;
	char title1[80];
  	float sdr,sdrdB;
        float norm;
	char theName[100];
#ifdef TCL_SUPPORT
        Tcl_Obj *varNameObj_P;
        Tcl_Obj *objVar_P;
#endif


Top

Initialization Code



 

        /*                                                      
         * allocate arrays                                      
         */                                                     
        xpts = (float* )calloc(npts,sizeof(float));           
        ypts = (float* )calloc(npts,sizeof(float));           
	if(ibufs > 1) {
		fprintf(stderr,"plot: only one  input allowed \n");
		return(5);
	}
	/* store as state the number of input/output buffers */
	if((ibufs = NO_INPUT_BUFFERS()) <= 0) {
		fprintf(stderr,"plot: no inputs connected\n");
		return(2);
	}
	if((obufs = NO_OUTPUT_BUFFERS()) > ibufs) {
		fprintf(stderr,"plot: too many outputs connected\n");
		return(3);
	}
        /*
	 * compute the power of 2 number of fft points
	 */
	fftexp = (int) (log((float)npts)/log(2.0)+0.5);
	fftl = 1 << fftexp;
	if (fftl > npts ) {
		fftl = fftl/2;
		fftexp -= 1;
	}
        spect = (float* )calloc(2*fftl,sizeof(float));           
        cfg=cap_fft_alloc(fftl,0,NULL,NULL);
        if ((cxinBuff = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL)
        {
                fprintf(stderr,"cmxfft: can't allocate work space \n");
                return(6);
        }
        if ((cxoutBuff = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL)
        {
             fprintf(stderr,"cmxfft: can't allocate work space \n");
             return(7);
        }





Top

Main Code



 


	for(samples = MIN_AVAIL(); samples > 0; --samples) {
		for(i=0; i i) {
				if(IT_OUT(i)) {
					KrnOverflow("sdr",i);
					return(99);
				}
	 			OUTF(i,0) = INF(i,0);
			}
	        }

		if(++total_count > skip) {
			for(i=0; i= npts) {
                            norm=1.0/(float)fftl;
			    for(i=0; i
    
Top

Wrapup Code



 
       free((cap_fft_cpx*)cxinBuff);
        free((cap_fft_cpx*)cxoutBuff);
        free((char*)spect);
                                                                                





Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/* sdr.s */
/**********************************************************************
                                sdr()
***********************************************************************
	inputs:		(One channel)
	outputs:	(optional feed-through of input channels)
	parameters:	int npts, the number of points to use 
			int skip, number of points to skip before calculation 
			window flag (0=Rect 1= Hamming)
*************************************************************************
Programmer: 	Sasan Ardalan
Date: 		2/16/89
Modified:	L.J. Faber 1/3/89.  Add flow through; general cleanup.
*/