Mercurial > hg > aimc
changeset 247:4039da654583
- Fix bug where the fram period wasn't propagating to the output file.
author | tom@acousticscale.org |
---|---|
date | Tue, 26 Oct 2010 16:46:14 +0000 |
parents | 0a3342606855 |
children | 976459a8f68b |
files | src/Modules/Features/ModuleGaussians.cc src/Modules/Output/FileOutputHTK.cc src/Modules/Output/FileOutputHTK.h |
diffstat | 3 files changed, 11 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Modules/Features/ModuleGaussians.cc Tue Oct 26 04:48:56 2010 +0000 +++ b/src/Modules/Features/ModuleGaussians.cc Tue Oct 26 16:46:14 2010 +0000 @@ -96,6 +96,7 @@ LOG_ERROR(_T("Module ModuleGaussians not initialized.")); return; } + output_.set_start_time(input.start_time()); // Calculate spectral profile for (int ch = 0; ch < input.channel_count(); ++ch) { m_pSpectralProfile[ch] = 0.0f;
--- a/src/Modules/Output/FileOutputHTK.cc Tue Oct 26 04:48:56 2010 +0000 +++ b/src/Modules/Output/FileOutputHTK.cc Tue Oct 26 16:46:14 2010 +0000 @@ -68,7 +68,7 @@ return false; } if (!header_written_) { - WriteHeader(channel_count_ * buffer_length_, frame_period_ms_); + WriteHeader(channel_count_ * buffer_length_); } return true; @@ -77,7 +77,7 @@ void FileOutputHTK::ResetInternal() { // Finalize and close the open file, if there is one. if (file_handle_ != NULL && !header_written_) { - WriteHeader(channel_count_ * buffer_length_, frame_period_ms_); + WriteHeader(channel_count_ * buffer_length_); } if (file_handle_ != NULL) CloseFile(); @@ -94,10 +94,10 @@ } sample_count_ = 0; header_written_ = false; - WriteHeader(channel_count_ * buffer_length_, frame_period_ms_); + WriteHeader(channel_count_ * buffer_length_); } -void FileOutputHTK::WriteHeader(int num_elements, float period_ms) { +void FileOutputHTK::WriteHeader(int num_elements) { if (header_written_) return; @@ -112,7 +112,7 @@ // To be filled in when the file is done int32_t sample_count = 0; - int32_t sample_period = floor(1e4 * period_ms); + int32_t sample_period = floor(1e4 * frame_period_ms_); int16_t sample_size = num_elements * sizeof(float); // NOLINT // User-defined coefficients with energy term @@ -170,12 +170,16 @@ // Write the first 4 bytes of the file // with how many samples there are in the file + // and the next 4 bytes with the frame period. fflush(file_handle_); rewind(file_handle_); fflush(file_handle_); int32_t samples = sample_count_; samples = ByteSwap32(samples); + int32_t sample_period = floor(1e4 * frame_period_ms_); + sample_period = ByteSwap32(sample_period); fwrite(&samples, sizeof(samples), 1, file_handle_); + fwrite(&sample_period, sizeof(sample_period), 1, file_handle_); // And close the file fclose(file_handle_);
--- a/src/Modules/Output/FileOutputHTK.h Tue Oct 26 04:48:56 2010 +0000 +++ b/src/Modules/Output/FileOutputHTK.h Tue Oct 26 16:46:14 2010 +0000 @@ -93,7 +93,7 @@ float ByteSwapFloat(float d); - void WriteHeader(int nelements, float sampPeriod); + void WriteHeader(int nelements); /*! \brief Whether initialization is done or not */