From: Kevin M. Rosenberg Date: Tue, 21 Jan 2003 04:20:06 +0000 (+0000) Subject: r3829: *** empty log message *** X-Git-Tag: v0.8.1~48 X-Git-Url: http://git.kpe.io/?p=wdq2wav.git;a=commitdiff_plain;h=d7a27230e4058ce4d949c22b68c758c90c46572b r3829: *** empty log message *** --- diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..9143146 --- /dev/null +++ b/.cvsignore @@ -0,0 +1 @@ +wdq2wav diff --git a/wdq2wav.cpp b/wdq2wav.cpp index 4a733e2..7a57e91 100644 --- a/wdq2wav.cpp +++ b/wdq2wav.cpp @@ -16,7 +16,7 @@ ** 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 @@ -35,7 +35,7 @@ #include static bool g_verbose = true; -static bool g_debug = true; +static bool g_debug = false; void error_msg (const char *msg) @@ -49,6 +49,12 @@ info_msg (const char* msg) fprintf (stdout, "%s\n", msg); } +void +info_msg_sans_newline (const char* msg) +{ + fprintf (stdout, "%s", msg); +} + void usage () { @@ -93,11 +99,24 @@ wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname) 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); @@ -108,16 +127,23 @@ wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname) 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); @@ -194,6 +220,18 @@ WindaqFile::ReadHeader () 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)) { diff --git a/wdq2wav.h b/wdq2wav.h index 9e83af9..fb8d0e0 100644 --- a/wdq2wav.h +++ b/wdq2wav.h @@ -5,7 +5,7 @@ #include #include #include - +#include class WindaqFile { @@ -23,6 +23,8 @@ public: unsigned int m_sr_denom, m_sr_numer; unsigned int m_nHeader_bytes, m_channel_offset, m_nBytes_channel_header; unsigned int m_nData_bytes; + unsigned long int m_time_acq_start; + unsigned long int m_time_acq_stop; }; class WindaqChannel