Capsim Block Documentation
Spectrum probe (plots both frequency and time domain). Float/Int/Complex input buffers.
int points; int samples; int numberPoints; int i,j,ii; float tmp; complex val; float wind; char title1[80]; char fname[80]; char curveSubTitle[80]; float* mag_P; float* phase_P; FILE *time_F; FILE *freq_F; |
---|
/* store as state the number of input/output buffers */ if((numberInputBuffers = NO_INPUT_BUFFERS()) <= 0) { fprintf(stderr,"spectrum: no inputs connected\n"); return(1); } if(numberInputBuffers > 1) { fprintf(stderr,"spectrum: only one input allowed \n"); return(2); } if((numberOutputBuffers = NO_OUTPUT_BUFFERS()) > numberInputBuffers) { fprintf(stderr,"spectrum: too many outputs connected\n"); return(3); } /* * Find closest power of two number */ fftexp = (int) (log((float)npts)/log(2.0)+0.5); fftl = 1 << fftexp; if (fftl > npts ) { fftl = fftl/2; fftexp -= 1; } if (control && mode == DYNAMIC) { /* * allocate arrays */ xfreq_P = (float* )calloc(npts,sizeof(float)); xTime_P = (float* )calloc(npts,sizeof(float)); if( bufferType == COMPLEX_BUFFER) ypts_P = (float* )calloc(2*npts,sizeof(float)); else ypts_P = (float* )calloc(npts,sizeof(float)); spect_P = (float* )calloc(2*fftl,sizeof(float)); if(xfreq_P == NULL || xTime_P ==NULL || ypts_P==NULL) { fprintf(stderr,"spectrum: could not allocate space\n"); return(5); } } else if(control && mode == STATIC) { /* * allocate arrays */ xfreq_P = (float* )calloc(BLOCK_SIZE,sizeof(float)); xTime_P = (float* )calloc(BLOCK_SIZE,sizeof(float)); if( bufferType == COMPLEX_BUFFER) ypts_P = (float* )calloc(2*BLOCK_SIZE,sizeof(float)); else ypts_P = (float* )calloc(BLOCK_SIZE,sizeof(float)); if(xfreq_P == NULL || xTime_P ==NULL || ypts_P==NULL) { fprintf(stderr,"spectrum: could not allocate space\n"); return(5); } } count = 0; totalCount = 0; switch(bufferType) { case COMPLEX_BUFFER: SET_CELL_SIZE_IN(0,sizeof(complex)); if(numberOutputBuffers == 1) SET_CELL_SIZE_OUT(0,sizeof(complex)); break; case FLOAT_BUFFER: SET_CELL_SIZE_IN(0,sizeof(float)); if(numberOutputBuffers == 1) SET_CELL_SIZE_OUT(0,sizeof(float)); break; case INTEGER_BUFFER: SET_CELL_SIZE_IN(0,sizeof(int)); if(numberOutputBuffers == 1) SET_CELL_SIZE_OUT(0,sizeof(int)); break; default: fprintf(stderr,"Bad buffer type specified in spectrum \n"); return(4); break; } |
---|
for(samples = MIN_AVAIL(); samples > 0; --samples) { for(i=0; i |
---|
if(control == 0) return(0); if((totalCount - skip) > 0 && mode ==STATIC) { /* * compute the power of 2 number of fft points */ fftexp = (int) (log((float)count)/log(2.0)+0.5); fftl = 1 << fftexp; if (fftl > count ) { fftl = fftl/2; fftexp -= 1; } spect_P = (float* )calloc(2*fftl,sizeof(float)); xfreq_P = (float *) realloc((char *) xfreq_P, sizeof(float) * (blockOff + bufi)); xTime_P = (float *) realloc((char *) xTime_P, sizeof(float) * (blockOff + bufi)); if(bufferType == COMPLEX_BUFFER) ypts_P = (float *) realloc((char *) ypts_P, sizeof(float) * 2*(blockOff + bufi)); else ypts_P = (float *) realloc((char *) ypts_P, sizeof(float) * (blockOff + bufi)); if(xfreq_P == NULL || ypts_P==NULL || xTime_P == NULL) { fprintf(stderr,"spectrum: could not allocate space\n"); return(8); } for(i=0; i |
---|
/* 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 */ |
---|
/* spectrumtxt.s */ /********************************************************************** spectrumtxt() *********************************************************************** inputs: (One channel) outputs: (optional feed-through of input channels) parameters: int npts, the number of points to plot int skip, number of points to skip before first plot file title, the title of the plot dB flag (0=linear 1=dB) window flag (0=Rect 1= Hamming Hanning=2 Blackman=3) ************************************************************************* This routine will produces the time domain and frequency domain spectrum of the input buffer. The first parameter represents the number of points plotted from the channel. Default is set to (int 128). The second parameter is the number of points to skip before the first plot set is presented. This enables skipping of any transient period. Default is set to (int 0). The third parameter represents the title for the plot. Default is set to "PLOT". The fourth parameter is the dB flag (0 for linear, 1 for dB ); The fifth parameter is the window flag ( 0 for Rectangular 1 for hammming) The sixth paramter determines the plotting style. The seventh parameter is used to turn the time domain plot on and off. The last parameter is used to plot agains bin number , frequency, or normalized axis. Programmer: Sasan Ardalan, Ramin Nobakht Date: 2/16/89 Modified: L.J. Faber 1/3/89. Add flow through; general cleanup. modified for Hanning & Blackman window Ali Sadri, Oct. 11, 1991. Modified: Sasan Ardalan, June 3, 1993 Added Dynamic Display. */ |
---|