Capsim Block Documentation

- License
- Description
- Input Connections
- Output Connections
- Parameters
- Result Variables
- States
- Declarations
- Initialization Code
- Main Code
- Wrapup Code

This star generates a selectable number of samples from an AR process represented as an IIR filter driven by Gaussian noise

int i,j; float sum; int max = 0x7fffffff; double s,t,u,v,k,w,x; float y1,y2; long random(); |
---|

if((outbufs = NO_OUTPUT_BUFFERS()) < 1 ) { fprintf(stderr,"arprocess: no output buffers connected\n"); return(3); } if (variance < 0.0 ) { fprintf(stderr,"arprocess: improper parameter\n"); return(1); } /* * pacer code */ no_inbuf = NO_INPUT_BUFFERS(); if(no_inbuf == 1) output_target = samples_first_time; else output_target = num_of_samples; if(output_target > num_of_samples) output_target = num_of_samples; if(pace_rate < 0) pace_rate = -pace_rate; /* * end pacer code */ fprintf(stderr,"var = %f\n",variance); dev = sqrt(variance); SET_DMAX_OUT(0,n_weights); fprintf(stderr,"dev = %f\n",dev); |
---|

if(no_inbuf == 1) { while(IT_IN(0)) pace_in_total += 1.0; if(pass == 1) { output_target = samples_first_time + (int) (pace_rate * pace_in_total + 0.5); if(output_target > num_of_samples && num_of_samples > 0) output_target = num_of_samples; } } pass = 1; i = 0; while(samples_out_total < output_target) { /* return if all samples have been output */ if(++i > NUMBER_SAMPLES_PER_VISIT) return(0); sum = 0; for(j=0; j |
---|

/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks) Copyright (C) 1989-2002 XCAD 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://capsimtmk.sourceforge.net XCAD Corporation Raleigh, North Carolina */ |
---|

/* arprocess.s */ /********************************************************************** arprocess() *********************************************************************** This star generates a selectable number of samples from an AR process, represented as an IIR filter driven by Gaussian noise. The order of the process, and the weighting values can be selected, via array parameter 2. Maximum order is 10 (since this is max array size). Parameter 3 selects the variance of the gaussian driving noise. This star supports auto-fanout. CONTROL PARAMETERS: num_of_samples = total number of samples to output. pace_rate = multiplies the number of samples received on pace input (if connected) to determine how many samples to output. samples_first_time = the number of samples to put out on the first call if pace input connected. It can be zero. negative values = 0. CONTROL DESCRIPTION: If the pace input is not connected: The num_of_samples parameter sets the maximum number of samples that the star will output. If num_of_samples < 0, an indefinite number of samples can be output. The star will output a maximum of NUMBER_SAMPLES_PER_VISIT on each call. If the pace input is connected: The num_of_samples parameter sets the maximum number of samples that the star will output. If num_samples_out < 0, an infinite number of samples can be output. The pace input paces the number of output samples on each call. At each call of the star all samples are read from the pace input and a running total of how many there have been is kept. An output_target is computed at each pass = pace_input_total * pace_rate. If pace_rate < 0, the absolute value is used. On the first call: output = lesser of (samples_first_time, num_of_samples) On subsequent calls: output = lesser of (NUMBER_SAMPLES_PER_VISIT, output_target) output_target = samples_first_time + pace_rate * pace_input_total - to that point The total number of samples that will be output: samples_out_total = lesser of (num_of_samples, samples_first_time + pace_rate * pace_input_total) |
---|