annotate trunk/src/Main/aimc.cc @ 318:30dde71d0230

- Modified licence from GPL 3 to Apache v2
author tomwalters
date Tue, 30 Mar 2010 22:06:24 +0000
parents 10d0803e37ec
children c74acd46121b
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@318 6 // Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@318 7 // you may not use this file except in compliance with the License.
tomwalters@318 8 // You may obtain a copy of the License at
tomwalters@268 9 //
tomwalters@318 10 // http://www.apache.org/licenses/LICENSE-2.0
tomwalters@268 11 //
tomwalters@318 12 // Unless required by applicable law or agreed to in writing, software
tomwalters@318 13 // distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@318 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@318 15 // See the License for the specific language governing permissions and
tomwalters@318 16 // limitations under the License.
tomwalters@268 17
tomwalters@280 18 #include <stdlib.h>
tomwalters@280 19
tomwalters@278 20 #include <string>
tomwalters@278 21
tomwalters@278 22 #include "Modules/Input/ModuleFileInput.h"
tomwalters@278 23 #include "Modules/BMM/ModuleGammatone.h"
tomwalters@278 24 #include "Modules/BMM/ModulePZFC.h"
tomwalters@278 25 #include "Modules/NAP/ModuleHCL.h"
tomwalters@278 26 #include "Modules/Strobes/ModuleParabola.h"
tomwalters@278 27 #include "Modules/SAI/ModuleSAI.h"
tomwalters@288 28 #include "Modules/SSI/ModuleSSI.h"
tomwalters@288 29 #include "Modules/Profile/ModuleSlice.h"
tomwalters@292 30 #include "Modules/Profile/ModuleScaler.h"
tomwalters@278 31 #include "Modules/Features/ModuleGaussians.h"
tomwalters@278 32 #include "Modules/Output/FileOutputHTK.h"
tomwalters@278 33
tomwalters@280 34 int main(int argc, char* argv[]) {
tomwalters@278 35 aimc::Parameters params;
tomwalters@292 36
tomwalters@292 37 int buffer_length = 480;
tomwalters@292 38 params.SetInt("input.buffersize", buffer_length);
tomwalters@292 39 params.SetBool("slice.normalize", true);
tomwalters@292 40 params.SetFloat("nap.lowpass_cutoff", 100.0f);
tomwalters@292 41
tomwalters@278 42 aimc::ModuleFileInput input(&params);
tomwalters@288 43 aimc::ModuleGammatone bmm(&params);
tomwalters@289 44 // aimc::ModulePZFC bmm(&params);
tomwalters@278 45 aimc::ModuleHCL nap(&params);
tomwalters@292 46 // aimc::ModuleParabola strobes(&params);
tomwalters@292 47 // aimc::ModuleSAI sai(&params);
tomwalters@292 48 // aimc::ModuleSSI ssi(&params);
tomwalters@288 49 aimc::ModuleSlice profile(&params);
tomwalters@292 50 aimc::ModuleScaler scaler(&params);
tomwalters@278 51 aimc::ModuleGaussians features(&params);
tomwalters@278 52 aimc::FileOutputHTK output(&params);
tomwalters@278 53
tomwalters@278 54 std::string parameters_string = params.WriteString();
tomwalters@278 55 printf("%s", parameters_string.c_str());
tomwalters@278 56
tomwalters@278 57 input.AddTarget(&bmm);
tomwalters@278 58 bmm.AddTarget(&nap);
tomwalters@292 59 nap.AddTarget(&profile);
tomwalters@292 60 //strobes.AddTarget(&sai);
tomwalters@292 61 //sai.AddTarget(&ssi);
tomwalters@292 62 //ssi.AddTarget(&profile);
tomwalters@292 63 profile.AddTarget(&scaler);
tomwalters@292 64 scaler.AddTarget(&features);
tomwalters@278 65 features.AddTarget(&output);
tomwalters@278 66
tomwalters@292 67 float frame_period_ms = 1000.0f * buffer_length
tomwalters@292 68 / input.GetOutputBank()->sample_rate();
tomwalters@292 69
tomwalters@292 70 output.OpenFile("test_output.htk", frame_period_ms);
tomwalters@292 71 if (input.LoadFile("test.wav")) {
tomwalters@292 72 input.Process();
tomwalters@292 73 } else {
tomwalters@292 74 printf("LoadFile failed");
tomwalters@292 75 }
tomwalters@292 76
tomwalters@292 77 input.Reset();
tomwalters@292 78 output.OpenFile("test_output_2.htk", frame_period_ms);
tomwalters@278 79 if (input.LoadFile("test.wav")) {
tomwalters@278 80 input.Process();
tomwalters@278 81 } else {
tomwalters@278 82 printf("LoadFile failed");
tomwalters@278 83 }
tomwalters@280 84 }