r3829: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 21 Jan 2003 04:20:06 +0000 (04:20 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 21 Jan 2003 04:20:06 +0000 (04:20 +0000)
.cvsignore [new file with mode: 0644]
wdq2wav.cpp
wdq2wav.h

diff --git a/.cvsignore b/.cvsignore
new file mode 100644 (file)
index 0000000..9143146
--- /dev/null
@@ -0,0 +1 @@
+wdq2wav
index 4a733e25d0d34a4f4e0bb8bc685a2ecc2d8f69a8..7a57e9181ddad913ac3674501b30fc4194e59d5e 100644 (file)
@@ -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 <wdq2wav.h>
 
 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)) {
index 9e83af9d45668084b1c38a25aaa875f0ec5af47e..fb8d0e00809c98f8741c67de225407de2c347a5b 100644 (file)
--- a/wdq2wav.h
+++ b/wdq2wav.h
@@ -5,7 +5,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sstream>
-
+#include <time.h>
 
 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