annotate src/Main/aimc.cc @ 20:fff25824d1d1

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