comparison trunk/src/Modules/Output/FileOutputAIMC.cc @ 322:1c0723041971

-Renamed sample_count to frame_count - a more accurate description.
author tomwalters
date Mon, 07 Jun 2010 08:38:21 +0000
parents c74acd46121b
children 3ee03a6b95a0
comparison
equal deleted inserted replaced
321:e7bcaf1e87d5 322:1c0723041971
65 // Check that the output file exists and is writeable 65 // Check that the output file exists and is writeable
66 if ((file_handle_ = fopen(filename, "wb")) == NULL) { 66 if ((file_handle_ = fopen(filename, "wb")) == NULL) {
67 LOG_ERROR(_T("Couldn't open output file '%s' for writing."), filename); 67 LOG_ERROR(_T("Couldn't open output file '%s' for writing."), filename);
68 return false; 68 return false;
69 } 69 }
70 sample_count_ = 0; 70 frame_count_ = 0;
71 frame_period_ms_ = frame_period_ms; 71 frame_period_ms_ = frame_period_ms;
72 header_written_ = false; 72 header_written_ = false;
73 if (initialized_) { 73 if (initialized_) {
74 WriteHeader(); 74 WriteHeader();
75 } 75 }
117 * 117 *
118 * Data: Series of floats, by time, then channel, then frame 118 * Data: Series of floats, by time, then channel, then frame
119 * f1c1t1,f1c1t2,f1c1t3... 119 * f1c1t1,f1c1t2,f1c1t3...
120 */ 120 */
121 121
122 uint32_t sample_count_out = sample_count_; 122 uint32_t frame_count_out = frame_count_;
123 float sample_period_out = frame_period_ms_; 123 float sample_period_out = frame_period_ms_;
124 uint32_t channels_out = channel_count_; 124 uint32_t channels_out = channel_count_;
125 uint32_t samples_out = buffer_length_; 125 uint32_t samples_out = buffer_length_;
126 float sample_rate = sample_rate_; 126 float sample_rate = sample_rate_;
127 127
128 fwrite(&sample_count_out, sizeof(sample_count_out), 1, file_handle_); 128 fwrite(&frame_count_out, sizeof(frame_count_out), 1, file_handle_);
129 fwrite(&sample_period_out, sizeof(sample_period_out), 1, file_handle_); 129 fwrite(&sample_period_out, sizeof(sample_period_out), 1, file_handle_);
130 fwrite(&channels_out, sizeof(channels_out), 1, file_handle_); 130 fwrite(&channels_out, sizeof(channels_out), 1, file_handle_);
131 fwrite(&samples_out, sizeof(samples_out), 1, file_handle_); 131 fwrite(&samples_out, sizeof(samples_out), 1, file_handle_);
132 fwrite(&sample_rate, sizeof(sample_rate), 1, file_handle_); 132 fwrite(&sample_rate, sizeof(sample_rate), 1, file_handle_);
133 fflush(file_handle_); 133 fflush(file_handle_);
154 for (int i = 0; i < input.buffer_length(); i++) { 154 for (int i = 0; i < input.buffer_length(); i++) {
155 s = input.sample(ch, i); 155 s = input.sample(ch, i);
156 fwrite(&s, sizeof(s), 1, file_handle_); 156 fwrite(&s, sizeof(s), 1, file_handle_);
157 } 157 }
158 } 158 }
159 sample_count_++; 159 frame_count_++;
160 } 160 }
161 161
162 bool FileOutputAIMC::CloseFile() { 162 bool FileOutputAIMC::CloseFile() {
163 if (file_handle_ == NULL) 163 if (file_handle_ == NULL)
164 return false; 164 return false;
166 // Write the first 4 bytes of the file 166 // Write the first 4 bytes of the file
167 // with how many samples there are in the file 167 // with how many samples there are in the file
168 fflush(file_handle_); 168 fflush(file_handle_);
169 rewind(file_handle_); 169 rewind(file_handle_);
170 fflush(file_handle_); 170 fflush(file_handle_);
171 uint32_t samples = sample_count_; 171 uint32_t frame_count = frame_count_;
172 fwrite(&samples, sizeof(samples), 1, file_handle_); 172 fwrite(&frame_count, sizeof(frame_count), 1, file_handle_);
173 173
174 // And close the file 174 // And close the file
175 fclose(file_handle_); 175 fclose(file_handle_);
176 file_handle_ = NULL; 176 file_handle_ = NULL;
177 header_written_ = false; 177 header_written_ = false;