r3822: Auto commit for Debian build
authorKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 21 Jan 2003 03:03:49 +0000 (03:03 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Tue, 21 Jan 2003 03:03:49 +0000 (03:03 +0000)
debian/changelog
wdq2wav.cpp
wdq2wav.h

index 7ed91ced824ca501d8774e9d0fd8b9b372bbfa09..72870bcd43c72cdfd3f1389e8b67fc1d14029f83 100644 (file)
@@ -1,3 +1,9 @@
+wdq2wav (0.2-1) unstable; urgency=low
+
+  * New upstream 
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 20 Jan 2003 20:03:39 -0700
+
 wdq2wav (0.1-1) unstable; urgency=low
 
   * Initial Release.
index bc0ae3b9cc021e719308a6ad5ec7d2ade87cd68b..326e8d4d270e5aadc8b990ec653a3fb59030edb7 100644 (file)
 **   Allocates memory equal to the size of channel (2 * number of samples)
 **
 **  BUGS
-**   Need to abstract error checking so it is not so redundant
 **   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.1 2003/01/21 01:58:32 kevin Exp $
+**  $Id: wdq2wav.cpp,v 1.2 2003/01/21 03:03:49 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
@@ -44,10 +43,16 @@ error_msg (char *msg)
   fprintf (stderr, "%s\n",msg);
 }
 
+void
+info_msg (char* msg)
+{
+  fprintf (stdout, "%s\n", msg);
+}
+
 void
 usage ()
 {
-  fprintf (stderr, "usage: wdq2wav <wdq-file> <channel-number> <wav-file>\n");
+  error_msg ("usage: wdq2wav <wdq-file> <channel-number> <wav-file>");
 }
 
 bool wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname);
@@ -66,7 +71,9 @@ main (int argc, char *argv[])
   char *wav_fname = argv[3];
 
   if (*channel_endptr != 0) {
-    fprintf (stderr, "Error: Channel %s is not an integer\n", argv[2]);
+    std::ostringstream os;
+    os << "Error: Channel " << argv[2] << " is not an integer";
+    error_str (os.str().c_str());
     usage();
     return(1);
   }
@@ -77,18 +84,20 @@ main (int argc, char *argv[])
   return 0;
 }
 
-bool wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname)
+bool
+wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname)
 {
   WindaqFile wdq (wdq_fname);
 
   if (! wdq.ReadHeader()) {
-    fprintf (stderr, "Error reading header %s\n", wdq_fname);
     return false;
   }
   if (g_verbose) {
-    printf ("Number of channels: %d\n", wdq.m_nChannels);
-    printf ("Number of Samples: %d\n", wdq.m_nSamples);
-    printf ("Sample Rate: %.1f\n", wdq.m_sample_rate);
+    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());
   }
   
   WindaqChannel wdq_channel (wdq, channel);
@@ -98,8 +107,17 @@ bool wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname)
   }
 
   if (g_verbose) {
-    printf ("Data Min: %f, Data Max: %f\n", 
-           wdq_channel.m_min_raw_data, wdq_channel.m_max_raw_data);
+    std::ostringstream os1;
+    os1 << "Channel units: " << wdq_channel.m_units.c_str();
+    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;
+    info_msg (os2.str().c_str());
+    std::ostringstream os3;
+    os3 << "Slope " <<  wdq_channel.m_slope <<
+      ", Intercept " <<  wdq_channel.m_intercept;
+    info_msg (os3.str().c_str());
   }
 
   WavFile wav (wdq_channel, wav_fname);
@@ -183,7 +201,9 @@ WindaqFile::ReadHeader ()
     return false;
   }
   if (tmp2 != 0x8001) {
-    fprintf (stderr, "%s is not a WinDAQ file\n", m_strFile.c_str());
+    std::ostringstream os;
+    os << m_strFile << " is not a WinDAQ file";
+    error_msg (os.str().c_str());
     return false;
   }
 
@@ -200,9 +220,12 @@ WindaqChannel::WindaqChannel (WindaqFile& wdq, const int channel)
     if (channel >= 1 && channel <= wdq.m_nChannels) {
       m_valid = true;
       read_channel_data();
-    } else
-      fprintf (stderr, "Channel %d is invalid, valid range 1-%d\n",
-             channel, wdq.m_nChannels);
+    } else {
+      std::ostringstream os;
+      os << "Channel " << channel << " is invalid, valid range 1-" <<
+       wdq.m_nChannels;
+      error_msg (os.str().c_str());
+    }
   }
 }
 
@@ -240,9 +263,6 @@ WindaqChannel::read_channel_data ()
   }
   m_intercept = float8;
 
-  if (g_verbose)
-    printf ("Slope: %f, Intercept: %f\n", m_slope, m_intercept);
-
   char units[7];
   units[6] = 0;
   if (read (fd, units, 6) != 6) {
@@ -250,8 +270,6 @@ WindaqChannel::read_channel_data ()
     return false;
   }
   m_units = units;
-  if (g_verbose)
-    printf ("Units: %s\n", units);
  
   unsigned int row_bytes = 2 * r_wdq.m_nChannels;
   signed short int sample_row [row_bytes];
@@ -263,7 +281,9 @@ WindaqChannel::read_channel_data ()
   signed short int data_max, data_min;
   for (i = 0; i < r_wdq.m_nSamples; i++) {
     if (read (fd, sample_row, row_bytes) != row_bytes) {
-      fprintf (stderr, "Error reading file at %d\n", i);
+      std::ostringstream os;
+      os << "Error reading file at " << i;
+      error_msg (os.str().c_str());
       return false;
     }
     
@@ -350,7 +370,9 @@ WavFile::WriteFile ()
   if (m_fd == 0)
     if ((m_fd = open (m_strFile.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == 0) {
-      fprintf (stderr, "Error opening output file %s\n", m_strFile.c_str());
+      std::ostringstream os;
+      os << "Error opening output file ", << m_strFile.c_str();
+      error_msg (os);
       return false;
     }
 
index 0c351640e34a31d016a596c585b30be42db4f072..e0f2e5019930ba69cefc4377149a6e0710eea864 100644 (file)
--- a/wdq2wav.h
+++ b/wdq2wav.h
@@ -4,6 +4,8 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <strstream>
+
 
 class WindaqFile
 {