** Need command line options for verbose and debug output
** Should comment the reading and writing of files to document the file formats
**
-** $Id: wdq2wav.cpp,v 1.6 2003/01/21 03:06:59 kevin Exp $
+** $Id: wdq2wav.cpp,v 1.7 2003/01/21 04:19:44 kevin Exp $
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License (version 2) as
#include <wdq2wav.h>
static bool g_verbose = true;
-static bool g_debug = true;
+static bool g_debug = false;
void
error_msg (const char *msg)
fprintf (stdout, "%s\n", msg);
}
+void
+info_msg_sans_newline (const char* msg)
+{
+ fprintf (stdout, "%s", msg);
+}
+
void
usage ()
{
return false;
}
if (g_verbose) {
- std::ostringstream os;
- os << wdq_fname << ": Samples " << wdq.m_nSamples <<
- ", Channels " << wdq.m_nChannels <<
- ", Sample Rate " << wdq.m_sample_rate;
- info_msg (os.str().c_str());
+ std::ostringstream os1;
+ os1 << "File " << wdq_fname;
+ info_msg (os1.str().c_str());
+ std::ostringstream os2;
+ time_t time = wdq.m_time_acq_start;
+ struct tm* tm = gmtime (&time);
+ os2 << " Time File Creation: " << asctime(tm);
+ info_msg_sans_newline (os2.str().c_str());
+ std::ostringstream os3;
+ time = wdq.m_time_acq_stop;
+ tm = gmtime (&time);
+ os3 << " Time File Written: " << asctime(tm);
+ info_msg_sans_newline (os3.str().c_str());
+ std::ostringstream os4;
+ os4 << " Samples: " << wdq.m_nSamples <<
+ ", Channels: " << wdq.m_nChannels <<
+ ", Sample Rate: " << wdq.m_sample_rate;
+ info_msg (os4.str().c_str());
}
WindaqChannel wdq_channel (wdq, channel);
if (g_verbose) {
std::ostringstream os1;
- os1 << "Channel units: " << wdq_channel.m_units.c_str();
+ os1 << "Channel " << channel;
info_msg (os1.str().c_str());
std::ostringstream os2;
- os2 << "Raw data: minimum " << wdq_channel.m_min_raw_data <<
- ", maximum " << wdq_channel.m_max_raw_data;
+ os2 << " Units: " << wdq_channel.m_units.c_str();
info_msg (os2.str().c_str());
std::ostringstream os3;
- os3 << "Slope " << wdq_channel.m_slope <<
- ", Intercept " << wdq_channel.m_intercept;
+ os3 << " Raw minimum: " << wdq_channel.m_min_raw_data <<
+ ", maximum: " << wdq_channel.m_max_raw_data;
info_msg (os3.str().c_str());
+ std::ostringstream os4;
+ os4 << " Scaled minimum: " << wdq_channel.m_min_scaled_data <<
+ ", maximum: " << wdq_channel.m_max_scaled_data;
+ info_msg (os4.str().c_str());
+ std::ostringstream os5;
+ os5 << " Slope " << wdq_channel.m_slope <<
+ ", Intercept " << wdq_channel.m_intercept;
+ info_msg (os5.str().c_str());
}
WavFile wav (wdq_channel, wav_fname);
m_nData_bytes = tmp4;
m_nSamples = (m_nData_bytes / m_nChannels) / 2;
+ lseek (m_fd, 36, SEEK_SET);
+ if (read (m_fd, &tmp4, sizeof(tmp4)) != sizeof(tmp4)) {
+ error_msg ("Error reading file");
+ return false;
+ }
+ m_time_acq_start = tmp4;
+ if (read (m_fd, &tmp4, sizeof(tmp4)) != sizeof(tmp4)) {
+ error_msg ("Error reading file");
+ return false;
+ }
+ m_time_acq_stop = tmp4;
+
// Verify Windaq signature
lseek (m_fd, m_nHeader_bytes - 2, SEEK_SET);
if (read (m_fd, &tmp2, sizeof(tmp2)) != sizeof(tmp2)) {