comparison trunk/src/Modules/Output/FileOutputHTK.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 aeac9e2151c6
comparison
equal deleted inserted replaced
291:2d3cef76b073 292:10d0803e37ec
67 return false; 67 return false;
68 } 68 }
69 sample_count_ = 0; 69 sample_count_ = 0;
70 frame_period_ms_ = frame_period_ms; 70 frame_period_ms_ = frame_period_ms;
71 header_written_ = false; 71 header_written_ = false;
72 if (initialized_) {
73 WriteHeader(channel_count_ * buffer_length_, frame_period_ms_);
74 }
72 return true; 75 return true;
73 } 76 }
74 77
75 bool FileOutputHTK::InitializeInternal(const SignalBank &input) { 78 bool FileOutputHTK::InitializeInternal(const SignalBank &input) {
76 if (file_handle_ == NULL) { 79 if (file_handle_ == NULL) {
77 LOG_ERROR(_T("Couldn't initialize file output. " 80 LOG_ERROR(_T("Couldn't initialize file output. "
78 "Please call FileOutputHTK::OpenFile first")); 81 "Please call FileOutputHTK::OpenFile first"));
79 return false; 82 return false;
80 } 83 }
81 if (header_written_) { 84 if (header_written_) {
82 LOG_ERROR(_T("A header has already been written on the output file." 85 LOG_ERROR(_T("A header has already been written on the output file. "
83 "Please call FileOutputHTK::CloseFile to close that file, " 86 "Please call FileOutputHTK::CloseFile to close that file, "
84 "and FileOutputHTK::OpenFile to open an new one before " 87 "and FileOutputHTK::OpenFile to open an new one before "
85 "calling FileOutputHTK::Initialize again.")); 88 "calling FileOutputHTK::Initialize again."));
86 return false; 89 return false;
87 } 90 }
93 96
94 void FileOutputHTK::ResetInternal() { 97 void FileOutputHTK::ResetInternal() {
95 if (file_handle_ != NULL && !header_written_) { 98 if (file_handle_ != NULL && !header_written_) {
96 WriteHeader(channel_count_ * buffer_length_, frame_period_ms_); 99 WriteHeader(channel_count_ * buffer_length_, frame_period_ms_);
97 } 100 }
101 if (file_handle_ != NULL)
102 CloseFile();
98 } 103 }
99 104
100 void FileOutputHTK::WriteHeader(int num_elements, float period_ms) { 105 void FileOutputHTK::WriteHeader(int num_elements, float period_ms) {
101 if (header_written_) 106 if (header_written_)
102 return; 107 return;
142 "Please call FileOutputHTK::OpenFile first")); 147 "Please call FileOutputHTK::OpenFile first"));
143 return; 148 return;
144 } 149 }
145 150
146 if (!header_written_) { 151 if (!header_written_) {
147 LOG_ERROR(_T("No header has been written on the output file yet. Please" 152 LOG_ERROR(_T("No header has been written on the output file yet. Please "
148 "call FileOutputHTK::Initialize() before calling " 153 "call FileOutputHTK::Initialize() before calling "
149 "FileOutputHTK::Process()")); 154 "FileOutputHTK::Process()"));
150 return; 155 return;
151 } 156 }
152 float s; 157 float s;
175 fwrite(&samples, sizeof(samples), 1, file_handle_); 180 fwrite(&samples, sizeof(samples), 1, file_handle_);
176 181
177 // And close the file 182 // And close the file
178 fclose(file_handle_); 183 fclose(file_handle_);
179 file_handle_ = NULL; 184 file_handle_ = NULL;
185 header_written_ = false;
180 return true; 186 return true;
181 } 187 }
182 188
183 float FileOutputHTK::ByteSwapFloat(float d) { 189 float FileOutputHTK::ByteSwapFloat(float d) {
184 // Endianness fix 190 // Endianness fix