00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <iostream>
00022 #include <string>
00023 #include "Util.h"
00024 #include "C1DMTSynthData.h"
00025 #include <iterator>
00026
00027 using namespace std;
00028
00029 int main(int argc, char *argv[]) {
00030 string version =
00031 "$Id: cag++.cpp 20 2005-11-11 12:57:01 +0100 (Fr, 11 Nov 2005) max $";
00032 cout << endl << endl;
00033 cout << "Program " << version << endl;
00034 cout << "Calculates 1D MT Responses from input models " << endl;
00035 cout
00036 << "Based on Cagniard algorithm, with stability enhancements taken from A. Avdeeva "
00037 << endl;
00038
00039 C1DMTSynthData Synthetic;
00040
00041
00042 double samplerate, freqstep;
00043 int samplelength;
00044 const double eps = 1e-5;
00045 string modelfilename, mttfilename;
00046 int mode = 0;
00047 try
00048 {
00049 if (argc == 2)
00050 {
00051 modelfilename = argv[1];
00052 mttfilename = modelfilename;
00053 mode = 0;
00054 }
00055 else
00056 {
00057 modelfilename = AskFilename("Model filename: ");
00058
00059 cout << "Output Format is .mtt ! Do not append ending. " << endl;
00060 mttfilename = AskFilename("Output filename: ");
00061
00062 cout << "Use Mode = 0 for standard calculation" << endl;
00063 cout << "Use Mode = 1 if you want frequencies to be calculated from sample rate and window length." << endl;
00064 cout << "Mode: ";
00065 cin >> mode;
00066 }
00067 Synthetic.ReadModel(modelfilename);
00068 if (mode == 1)
00069 {
00070 cout << "Sampling rate: ";
00071 cin >> samplerate;
00072 cout << "Length for continuous sample: ";
00073 cin >> samplelength;
00074 freqstep = samplerate/samplelength;
00075 trealdata frequency;
00076 frequency.push_back(eps);
00077 for (int i = 1; i < samplelength/2; ++i)
00078 {
00079 frequency.push_back(freqstep * i);
00080 }
00081 Synthetic.SetFrequencies(frequency);
00082 }
00083
00084 Synthetic.GetData();
00085 Synthetic.WriteAsMtt(mttfilename);
00086 }
00087 catch(CFatalException &e)
00088 {
00089 cerr << e.what() << endl;
00090 return -1;
00091 }
00092 }