Listing 4

#include "statevar.h"
void statevar(struct sv *svp, double samplein)
{
        svp->lowpass = svp->lowpass+(svp->fc*svp->bandpass);
        svp->highpass = (samplein-svp->lowpass)-(svp->damp*svp->bandpass);
        svp->bandpass = (svp->fc*svp->highpass)+ svp->bandpass;
        svp->notch = svp->highpass+svp->lowpass;
}
void setstate(struct sv *svp, double corner, double samplef, 
                                         double Que, double fgain)
{
    svp->fc = sin(M_PI*corner/samplef);
    svp->damp = 1.0/Que;
    svp->gain = fgain;
    svp-> lowpass = 0;  //lowpass output
    svp-> bandpass = 0; //bandpass output
    svp-> highpass = 0; //highpass output
    svp-> notch = 0;    //notch output
    svp-> bp_last = 0;
    svp-> lp_last = 0;
//  svp-> gain = 0;     //gain
}