Exemple #1
1
int main(){

  /* run the pregenerated Chebyshev filter, then our own distillation
     through the generic and specialized code */
  float *work=_ogg_malloc(128*sizeof(float));
  IIR_state iir;
  int i;

  for(i=0;i<128;i++)work[i]=filterloop(data[i]);
  {
    FILE *out=fopen("IIR_ref.m","w");
    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
    fclose(out);
  }

  IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
  for(i=0;i<128;i++)work[i]=IIR_filter(&iir,data[i]);
  {
    FILE *out=fopen("IIR_gen.m","w");
    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
    fclose(out);
  }
  IIR_clear(&iir);  

  IIR_init(&iir,NPOLES,GAIN,cheb_bandpass_A,cheb_bandpass_B);
  for(i=0;i<128;i++)work[i]=IIR_filter_ChebBand(&iir,data[i]);
  {
    FILE *out=fopen("IIR_cheb.m","w");
    for(i=0;i<128;i++)fprintf(out,"%g\n",work[i]);
    fclose(out);
  }
  IIR_clear(&iir);  

  return(0);
}
Exemple #2
0
void main(){


//b0 b1 b2 a0 a1 a2
float_j_t Coefficient[Section][N_th_order]={
1,	-1.29632172693744,	1,	1,	-1.80515310279348,	0.88702449464002,
1,	0.38051527431782,	1,	1,	-1.80676488212313,	0.82648708617365,
1,	-1.55996982970591,	1,	1,	-1.82577026864564,	0.96274299269518
};
float_j_t Gain[Section+1]={  
0.29199951748161,
0.23303636811273,
0.00392996161525,
1
};

float_j_t state[Section][N_th_order/2]={0,}; //0 state is lastest



	int testcase ;
	scanf("%d",&testcase);
	int i;
	for(i=0;i<testcase;i++){
	float_j_t in;
	scanf("%f",&in);
	float_j_t st;
	IIR_filter(&st,in,0,Coefficient,Gain,state);
	IIR_filter(&st,st,1,Coefficient,Gain,state);
	IIR_filter(&st,st,2,Coefficient,Gain,state);
	printf("c %f\n",Gain[3]*st);
	}



}