19 #include "../fft/realFFT.H" 25 for (
int i=0;i<fCount;i++)
26 if (outputGT[i])
delete [] outputGT[i];
34 double **outputGT=NULL;
35 if (!(outputGT=
new double*[fCount])){
36 cerr<<
"filter bank malloc error initial"<<endl;
39 for (
int i=0;i<fCount;i++)
41 for (
int i=0;i<fCount;i++)
42 if (!(outputGT[i]=
new double[sCount])){
43 cerr<<
"filter bank malloc error secondary"<<endl;
51 #define INPUTFILENAME "fa.dat" 52 #define TMASKFILENAME "fa.t.mask" 53 #define BMASKFILENAME "fa.b.mask" 54 #define POWFILENAME "fa.pow" 55 #define EXCITEFILENAME "fa.excite" 66 int sampleCount=16384, halfSampleCount=(int)
rint((
double)sampleCount/2.0);
67 int count=50;
int lowFreq=100;
int sampleFreq=8192;
68 double input[sampleCount], **outputGT, **output;
76 for (
int i=0; i<sampleCount;i++)
77 inputF >> temp >> input[i];
80 powOutput=
FBMalloc(count, halfSampleCount);
81 outputGT=
FBMalloc(count, sampleCount);
82 for (
int i=0;i<count;i++)
83 bzero(outputGT[i], sampleCount*
sizeof(
double));
86 for (
int i=0;i<count;i++)
87 bzero(output[i], sampleCount*
sizeof(
double));
91 GCFB gcfb(lowFreq, sampleFreq, count);
92 gcfb.filter((
double*)input, outputGT, output, sampleCount);
94 GTFB gtfb(lowFreq, sampleFreq, count);
95 for (
int i=1; i<=count;i++)
96 gtfb.grab(i)->filter(input, &outputGT[i-1][0], sampleCount);
100 realFFTData fftData(sampleCount);
101 realFFT fft(&fftData);
102 for (
int i=0;i<count;i++){
103 for (
int j=0; j<sampleCount;j++)
104 fftData.in[j]=outputGT[i][j];
106 fftData.compPowerSpec();
107 for (
int j=0; j<halfSampleCount;j++){
108 powOutput[i][j]=sqrt(fftData.power_spectrum[j]);
119 for (
int i=0; i<count;i++)
121 mask.
setCFreq(i, gcfb.prev()->gt->cf);
130 for (
int i=0; i<count;i++)
132 outputF <<gcfb.prev()->gt->cf*((double)sampleCount/(
double)sampleFreq)<<
'\t'<< 20*log10(mask.
mask[i])<<
'\n';
134 outputF <<gtfb.prev()->cf*((double)sampleCount/(
double)sampleFreq)<<
'\t'<< 20*log10(mask.
mask[i])<<
'\n';
141 cout<<
"Done exciting"<<endl;
144 for (
int i=0; i<count;i++)
146 outputF <<gcfb.prev()->gt->cf*(sampleCount/sampleFreq)<<
'\t'<< 10*log10(mask.
mask[i])<<
'\n';
148 outputF <<gtfb.prev()->cf*(sampleCount/sampleFreq)<<
'\t'<< 10*log10(mask.
mask[i])<<
'\n';
155 for (
int j=0; j<sampleCount;j++)
156 fftData.in[j]=input[j];
158 fftData.compPowerSpec();
159 for (
int j=0; j<halfSampleCount;j++){
160 outputF<<j+1<<
'\t'<<20*log10(sqrt(fftData.power_spectrum[j]))<<endl;
void setCFreq(int which, double value)
double ** FBMalloc(int fCount, int sCount)
void exciteTerhardt(double **filterBankOutput, int sampleCount)
double * mask
The audio mask.
void FBDeMalloc(double **outputGT, int fCount)
void exciteBeerends(double **filterBankOutput, int sampleCount)