#include <math.h>
#define INPUTFILENAME "test/testVectors/audio.44100.txt" // input file - text written samples seperated by white spaces
#define POWFILENAME "/tmp/fa.pow" // The power spectrum of the input signal
#define THRESHFILENAME "/tmp/thresh.dat" // The masking threshold at each frequency of the input signal
#define TMASKFILENAME "/tmp/fa.t.mask" // The masking threshold for each filter CF
#define EXCITEFILENAME "/tmp/fa.excite" // The excitation
#include <fstream>
int main(
int argc,
char *argv[]) {
cout<<argc<<endl;
if (argc<2){
cout<<"Useage "<<argv[0]<<" fileName"<<endl;
cout<<"e.g. "<<argv[0]<<" INPUTFILENAME"<<endl;
cout<<
"\twhere fileName is an audio file text written samples seperated by white spaces, look for the file "<<
INPUTFILENAME<<
" which shipped with gtkIOStream for an example."<<endl;
exit(-1);
}
int sampleCount=1024, halfSampleCount=(int)
rint((
double)sampleCount/2.0);
int count=50, sampleFreq=44100;
int skip=8192-sampleCount-1;
double input[sampleCount];
ifstream inputF(argv[1]);
if (!inputF){
cerr<<"couldn't open the file "<<argv[1]<<endl;
exit(-1);
}
int temp;
for (int i=0; i<skip; i++)
inputF >> temp >> input[0];
for (int i=0; i<sampleCount; i++)
inputF >> input[i];
inputF.close();
masker.
excite(input, sampleCount);
for (int j=0; j<count; j++) {
outputT << 20*log10(masker.
mask[j])<<
'\t';
}
outputT<<endl;
for (int j=0; j<sampleCount; j++)
for (int j=0; j<sampleCount/2; j++)
outputP<<endl;
outputT.close();
outputP.close();
ofstream outputF(THRESHFILENAME);
double fact=(double)sampleFreq/((double)sampleCount-1.0);
for (int j=0; j<halfSampleCount; j++) {
}
outputF<<endl;
outputF.close();
ofstream octFile("/tmp/view.m");
octFile<<"% run this in octave : install octave"<<endl;
octFile<<"load -force "<<THRESHFILENAME<<endl;
octFile<<"whos"<<endl;
octFile<<"semilogx(1:length(fa), fa, 1:length(thresh), thresh)"<<endl;
octFile<<"legend('power spec.','masking threshold')"<<endl;
octFile<<"xlabel('Fourier Bin')"<<endl;
octFile<<"ylabel('Energy')"<<endl;
octFile<<"title('Typical masking example - vary the threshold up and down to change audio quality')"<<endl;
octFile<<"pause"<<endl;
octFile.close();
string tempPath="/tmp";
vector<string> args(3); args[0]=string("--silent"); args[1]=string("--path"); args[2]=tempPath;
}