Skip to content

Instantly share code, notes, and snippets.

@IanWraith
Created October 11, 2010 19:01
Show Gist options
  • Save IanWraith/621038 to your computer and use it in GitHub Desktop.
Save IanWraith/621038 to your computer and use it in GitHub Desktop.
// Filter details ..
// filtertype = Raised Cosine
// samplerate = 48000
// corner = 2400
// beta = 0.7
// impulselen = 21
// racos = sqrt
// comp = no
// bits =
// logmin =
private static final int NZEROS=20;
private static final double GAIN=1.063197639e+01;
private double xv[]=new double [NZEROS+1];
private static final double XCOEFFS[]=
{ -0.1142415065, -0.0652615756, +0.0266625160, +0.1613371679,
+0.3321186878, +0.5261565098, +0.7257137259, +0.9104055994,
+1.0600181526, +1.1574475610, +1.1912627108, +1.1574475610,
+1.0600181526, +0.9104055994, +0.7257137259, +0.5261565098,
+0.3321186878, +0.1613371679, +0.0266625160, -0.0652615756,
-0.1142415065,
};
// A root raised pulse shaping filter
public int rootRaisedFilter (int sample) {
int i;
double sum=0.0;
double in=(double) sample;
for (i=0;i<NZEROS;i++) {
xv[i]=xv[i+1];
}
xv[NZEROS]=in/GAIN;
for (i=0;i<=NZEROS;i++) {
sum=sum+(XCOEFFS[i]*xv[i]);
}
return (int)sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment