annotate trunk/src/Main/aimc.cc @ 292:10d0803e37ec

-Added a module to scale output values by the channel centre frequency -Fixed file input to support loading and processing of multiple files -Updated the aimc main file to generate profiles like in the recognition experiments
author tomwalters
date Mon, 22 Feb 2010 17:51:27 +0000
parents 6cf55200a199
children 30dde71d0230
rev   line source
tomwalters@278 1 // Copyright 2008-2010, Thomas Walters
tomwalters@268 2 //
tomwalters@268 3 // AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268 4 // http://www.acousticscale.org/AIMC
tomwalters@268 5 //
tomwalters@268 6 // This program is free software: you can redistribute it and/or modify
tomwalters@268 7 // it under the terms of the GNU General Public License as published by
tomwalters@268 8 // the Free Software Foundation, either version 3 of the License, or
tomwalters@268 9 // (at your option) any later version.
tomwalters@268 10 //
tomwalters@268 11 // This program is distributed in the hope that it will be useful,
tomwalters@268 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268 14 // GNU General Public License for more details.
tomwalters@268 15 //
tomwalters@268 16 // You should have received a copy of the GNU General Public License
tomwalters@268 17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@268 18
tomwalters@280 19 #include <stdlib.h>
tomwalters@280 20
tomwalters@278 21 #include <string>
tomwalters@278 22
tomwalters@278 23 #include "Modules/Input/ModuleFileInput.h"
tomwalters@278 24 #include "Modules/BMM/ModuleGammatone.h"
tomwalters@278 25 #include "Modules/BMM/ModulePZFC.h"
tomwalters@278 26 #include "Modules/NAP/ModuleHCL.h"
tomwalters@278 27 #include "Modules/Strobes/ModuleParabola.h"
tomwalters@278 28 #include "Modules/SAI/ModuleSAI.h"
tomwalters@288 29 #include "Modules/SSI/ModuleSSI.h"
tomwalters@288 30 #include "Modules/Profile/ModuleSlice.h"
tomwalters@292 31 #include "Modules/Profile/ModuleScaler.h"
tomwalters@278 32 #include "Modules/Features/ModuleGaussians.h"
tomwalters@278 33 #include "Modules/Output/FileOutputHTK.h"
tomwalters@278 34
tomwalters@280 35 int main(int argc, char* argv[]) {
tomwalters@278 36 aimc::Parameters params;
tomwalters@292 37
tomwalters@292 38 int buffer_length = 480;
tomwalters@292 39 params.SetInt("input.buffersize", buffer_length);
tomwalters@292 40 params.SetBool("slice.normalize", true);
tomwalters@292 41 params.SetFloat("nap.lowpass_cutoff", 100.0f);
tomwalters@292 42
tomwalters@278 43 aimc::ModuleFileInput input(&params);
tomwalters@288 44 aimc::ModuleGammatone bmm(&params);
tomwalters@289 45 // aimc::ModulePZFC bmm(&params);
tomwalters@278 46 aimc::ModuleHCL nap(&params);
tomwalters@292 47 // aimc::ModuleParabola strobes(&params);
tomwalters@292 48 // aimc::ModuleSAI sai(&params);
tomwalters@292 49 // aimc::ModuleSSI ssi(&params);
tomwalters@288 50 aimc::ModuleSlice profile(&params);
tomwalters@292 51 aimc::ModuleScaler scaler(&params);
tomwalters@278 52 aimc::ModuleGaussians features(&params);
tomwalters@278 53 aimc::FileOutputHTK output(&params);
tomwalters@278 54
tomwalters@278 55 std::string parameters_string = params.WriteString();
tomwalters@278 56 printf("%s", parameters_string.c_str());
tomwalters@278 57
tomwalters@278 58 input.AddTarget(&bmm);
tomwalters@278 59 bmm.AddTarget(&nap);
tomwalters@292 60 nap.AddTarget(&profile);
tomwalters@292 61 //strobes.AddTarget(&sai);
tomwalters@292 62 //sai.AddTarget(&ssi);
tomwalters@292 63 //ssi.AddTarget(&profile);
tomwalters@292 64 profile.AddTarget(&scaler);
tomwalters@292 65 scaler.AddTarget(&features);
tomwalters@278 66 features.AddTarget(&output);
tomwalters@278 67
tomwalters@292 68 float frame_period_ms = 1000.0f * buffer_length
tomwalters@292 69 / input.GetOutputBank()->sample_rate();
tomwalters@292 70
tomwalters@292 71 output.OpenFile("test_output.htk", frame_period_ms);
tomwalters@292 72 if (input.LoadFile("test.wav")) {
tomwalters@292 73 input.Process();
tomwalters@292 74 } else {
tomwalters@292 75 printf("LoadFile failed");
tomwalters@292 76 }
tomwalters@292 77
tomwalters@292 78 input.Reset();
tomwalters@292 79 output.OpenFile("test_output_2.htk", frame_period_ms);
tomwalters@278 80 if (input.LoadFile("test.wav")) {
tomwalters@278 81 input.Process();
tomwalters@278 82 } else {
tomwalters@278 83 printf("LoadFile failed");
tomwalters@278 84 }
tomwalters@280 85 }