annotate src/Main/aimc.cc @ 45:c5f5e9569863

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