r4107: Auto commit for Debian build
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 24 Feb 2003 08:40:25 +0000 (08:40 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 24 Feb 2003 08:40:25 +0000 (08:40 +0000)
debian/changelog
wdq2wav.cpp

index 14140298c167cb25e3b34fee0f0e2aed4b63433b..056c0bc374f91fc5313df0c4a95324f1afe166eb 100644 (file)
@@ -1,6 +1,12 @@
+wdq2wav (0.5.0-1) unstable; urgency=low
+
+  * New upstream, add support for scaling while preserving zero point
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon, 24 Feb 2003 01:39:51 -0700
+
 wdq2wav (0.4.0-1) unstable; urgency=low
 
-  * New upstream, add support for MSVC compilation.
+  * Support for MSVC compilation.
 
  -- Kevin M. Rosenberg <kmr@debian.org>  Tue, 11 Feb 2003 23:06:52 -0700
 
index 288a9c6c0e14e67b8357e567eecdd2000559e8de..16eddba4560d82de001f304ad988e9db325e0e7a 100644 (file)
@@ -8,7 +8,7 @@
 **
 **  Copyright (c) 2003 Kevin Rosenberg
 **
-**  $Id: wdq2wav.cpp,v 1.16 2003/02/12 07:24:32 kevin Exp $
+**  $Id: wdq2wav.cpp,v 1.17 2003/02/24 08:40:25 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>
 
-const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.16 2003/02/12 07:24:32 kevin Exp $";
+const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.17 2003/02/24 08:40:25 kevin Exp $";
 
 bool g_quiet = false;
 bool g_verbose = false;
 bool g_debug = false;
+bool g_ignore_zero = false;
 
 
 #ifdef WIN32
@@ -107,12 +108,13 @@ usage (const char* progname)
 {
   std::cout << "usage: " << fileBasename (progname) << " [OPTIONS] <wdq-file> <channel-number> <wav-file>\n";
   std::cout << "OPTIONS\n";
-  std::cout << "  -p    Play channel through audio system\n";
-  std::cout << "  -q    Supress all messages\n";
-  std::cout << "  -v    Verbose mode\n";
-  std::cout << "  -d    Debug mode\n";
-  std::cout << "  -r    Print program version\n";
-  std::cout << "  -h    Print this help message\n";
+  std::cout << "  -p   Play channel through audio system\n";
+  std::cout << "  -q   Supress all messages\n";
+  std::cout << "  -z   Scale output without regard for windaq zero point\n";
+  std::cout << "  -v   Verbose mode\n";
+  std::cout << "  -d   Debug mode\n";
+  std::cout << "  -r   Print program version\n";
+  std::cout << "  -h   Print this help message\n";
 }
 
 
@@ -254,6 +256,7 @@ wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname, bool p
       ", maximum: " << wdq_channel.m_max_raw_data;
     info_msg (os3.str().c_str());
   }
+  
   if (g_debug) {
     std::ostringstream os4;
     os4 << "  Scaled minimum: " << wdq_channel.m_min_scaled_data <<
@@ -511,12 +514,19 @@ WavFile::WavFile (WindaqChannel& wdq_channel, const char* fname)
     m_nBitsPerSample = 16;
     m_nBytesPerSample = 2;
     m_rate = wdq_channel.r_wdq.m_sample_rate;
-    
-    double data_offset = -wdq_channel.m_min_scaled_data;
-    double data_scale = 0.;
-    if (wdq_channel.m_max_scaled_data != wdq_channel.m_min_scaled_data)
-      data_scale = 65535. / (wdq_channel.m_max_scaled_data -
-                            wdq_channel.m_min_scaled_data);
+
+    double data_offset = 0, data_scale = 0;
+    if (g_ignore_zero) {
+      data_offset = -wdq_channel.m_min_scaled_data;
+      if (wdq_channel.m_max_scaled_data != wdq_channel.m_min_scaled_data)
+       data_scale = 65535. / (wdq_channel.m_max_scaled_data -
+                              wdq_channel.m_min_scaled_data);
+    } else {
+      double max_value = fabs(wdq_channel.m_max_scaled_data);
+      if (fabs(wdq_channel.m_min_scaled_data) > max_value)
+       max_value = fabs(wdq_channel.m_min_scaled_data);
+      data_scale = 32767. / max_value;
+    }
     
     if (g_debug) {
       std::ostringstream os;
@@ -544,7 +554,8 @@ WavFile::WavFile (WindaqChannel& wdq_channel, const char* fname)
       double value = input[i];
       value = (slope * value) + intercept;
       value = (value + data_offset) * data_scale;
-      value += 0.5 - 32768;
+      if (g_ignore_zero)
+       value += 0.5 - 32768;
       signed short int v = static_cast<signed short int>(value);
 #if WORDS_BIG_ENDIAN
       unsigned char* p = reinterpret_cast<unsigned char*>(&v);