29 extern double rint(
double);
31 #define FREQBINCOUNT 44100 57 double erb(
double fc){
58 return 24.7*(4.37*(fc/1000.0)+1.0);
66 return (
AM_C3*log10((
AM_C2 * freq/1000.0) + 1.0));
73 return 1000.0 * (pow(10.0,(erb/
AM_C3)) - 1.0) /
AM_C2;
81 virtual void af(
double fc,
int whichFilter){
87 g[i]=fabs((freq-fc)/fc);
91 double *filt=
w[whichFilter],
p;
99 filt[i]=(1.0+p*
g[i])*exp(-p*
g[i]);
112 for (
int i=0;i<
fCount;i++){
119 for (
int i=1;i<
fCount;i++){
140 return 4.0*fc/
erb(fc);
151 return 4.0*fc/
erb(fc);
163 init(sampleFreq, fCnt);
171 void init(
int sampleFreq,
int fCnt=50){
177 std::cerr<<
"DepUKFB::DepUKFB: g malloc error"<<std::endl;
180 if (!(w=
new double*[fCount])){
181 std::cerr<<
"DepUKFB::DepUKFB: w malloc error"<<std::endl;
184 for (
int i=0;i<
fCount;i++)
186 for (
int i=0;i<
fCount;i++){
187 if (!(w[i]=
new double[FREQBINCOUNT])){
188 std::cerr<<
"DepUKFB::DepUKFB: w[i] malloc error"<<std::endl;
194 if (!(cf=
new double[fCount])){
195 std::cerr<<
"DepUKFB::DepUKFB: cf malloc error"<<std::endl;
199 if (!(ef=
new double[fCount])){
200 std::cerr<<
"DepUKFB::DepUKFB: ef malloc error"<<std::endl;
207 for (
int i=0;i<
fCount;i++)
214 for (
int i=0;i<
fCount;i++)
215 if (w[i])
delete [] w[i];
218 if (cf)
delete []
cf;
219 if (ef)
delete []
ef;
double * cf
The filter centre frequencies.
DepUKFB(int sampleFreq, int fCnt=50)
double freq2ERB(double freq)
double * ef
The filter edge frequencies.
double ERB2freq(double erb)
double * operator[](int i)
double operator()(int i, int j, int binCount)
int fs
The sample frequency.
int filterCount(void)
Returns the number of filters.
void init(int sampleFreq, int fCnt=50)
virtual void af(double fc, int whichFilter)