tomwalters@6: // Copyright 2008-2010, Thomas Walters tomwalters@0: // tomwalters@0: // AIM-C: A C++ implementation of the Auditory Image Model tomwalters@0: // http://www.acousticscale.org/AIMC tomwalters@0: // tomwalters@45: // Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@45: // you may not use this file except in compliance with the License. tomwalters@45: // You may obtain a copy of the License at tomwalters@0: // tomwalters@45: // http://www.apache.org/licenses/LICENSE-2.0 tomwalters@0: // tomwalters@45: // Unless required by applicable law or agreed to in writing, software tomwalters@45: // distributed under the License is distributed on an "AS IS" BASIS, tomwalters@45: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@45: // See the License for the specific language governing permissions and tomwalters@45: // limitations under the License. tomwalters@0: tomwalters@8: #include tomwalters@8: tomwalters@6: #include tomwalters@6: tomwalters@6: #include "Modules/Input/ModuleFileInput.h" tomwalters@6: #include "Modules/BMM/ModuleGammatone.h" tomwalters@6: #include "Modules/BMM/ModulePZFC.h" tomwalters@6: #include "Modules/NAP/ModuleHCL.h" tomwalters@6: #include "Modules/Strobes/ModuleParabola.h" tomwalters@6: #include "Modules/SAI/ModuleSAI.h" tomwalters@16: #include "Modules/SSI/ModuleSSI.h" tomwalters@16: #include "Modules/Profile/ModuleSlice.h" tomwalters@20: #include "Modules/Profile/ModuleScaler.h" tomwalters@6: #include "Modules/Features/ModuleGaussians.h" tomwalters@6: #include "Modules/Output/FileOutputHTK.h" tomwalters@6: tomwalters@8: int main(int argc, char* argv[]) { tomwalters@6: aimc::Parameters params; tomwalters@20: tomwalters@20: int buffer_length = 480; tomwalters@20: params.SetInt("input.buffersize", buffer_length); tomwalters@20: params.SetBool("slice.normalize", true); tomwalters@20: params.SetFloat("nap.lowpass_cutoff", 100.0f); tomwalters@20: tomwalters@6: aimc::ModuleFileInput input(¶ms); tomwalters@16: aimc::ModuleGammatone bmm(¶ms); tomwalters@17: // aimc::ModulePZFC bmm(¶ms); tomwalters@6: aimc::ModuleHCL nap(¶ms); tomwalters@20: // aimc::ModuleParabola strobes(¶ms); tomwalters@20: // aimc::ModuleSAI sai(¶ms); tomwalters@20: // aimc::ModuleSSI ssi(¶ms); tomwalters@16: aimc::ModuleSlice profile(¶ms); tomwalters@20: aimc::ModuleScaler scaler(¶ms); tomwalters@6: aimc::ModuleGaussians features(¶ms); tomwalters@6: aimc::FileOutputHTK output(¶ms); tomwalters@6: tomwalters@6: std::string parameters_string = params.WriteString(); tomwalters@6: printf("%s", parameters_string.c_str()); tomwalters@6: tomwalters@6: input.AddTarget(&bmm); tomwalters@6: bmm.AddTarget(&nap); tomwalters@20: nap.AddTarget(&profile); tomwalters@20: //strobes.AddTarget(&sai); tomwalters@20: //sai.AddTarget(&ssi); tomwalters@20: //ssi.AddTarget(&profile); tomwalters@20: profile.AddTarget(&scaler); tomwalters@20: scaler.AddTarget(&features); tomwalters@6: features.AddTarget(&output); tomwalters@6: tomwalters@20: float frame_period_ms = 1000.0f * buffer_length tomwalters@20: / input.GetOutputBank()->sample_rate(); tomwalters@20: tomwalters@20: output.OpenFile("test_output.htk", frame_period_ms); tomwalters@20: if (input.LoadFile("test.wav")) { tomwalters@20: input.Process(); tomwalters@20: } else { tomwalters@20: printf("LoadFile failed"); tomwalters@20: } tomwalters@20: tomwalters@20: input.Reset(); tomwalters@20: output.OpenFile("test_output_2.htk", frame_period_ms); tomwalters@6: if (input.LoadFile("test.wav")) { tomwalters@6: input.Process(); tomwalters@6: } else { tomwalters@6: printf("LoadFile failed"); tomwalters@6: } tomwalters@8: }