r4131: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 28 Feb 2003 04:13:00 +0000 (04:13 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 28 Feb 2003 04:13:00 +0000 (04:13 +0000)
debian/changelog
wdq2wav.1
wdq2wav.cpp

index bf6f93792a2a0fcd523575fe7d194866eda98f40..6d23a57b09a6317e5e8565d708890ac7b940e0e2 100644 (file)
@@ -1,3 +1,10 @@
+wdq2wav (0.7.0-1) unstable; urgency=low
+
+  * Invert the meaning of the -z option
+  * Selection -m automatically sets -z
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Thu, 27 Feb 2003 21:12:55 -0700
+
 wdq2wav (0.6.0-1) unstable; urgency=low
 
   * Add demeaning option
 wdq2wav (0.6.0-1) unstable; urgency=low
 
   * Add demeaning option
index 2a0518e8a20dfd408f03a9b2697fd74dd31dd78f..2026807a8f949a6e1295eb47b44aa7349015c2ef 100644 (file)
--- a/wdq2wav.1
+++ b/wdq2wav.1
@@ -33,10 +33,13 @@ to enter thos values when the program is run.
 Play channel through audio system
 .TP
 .B \-m
 Play channel through audio system
 .TP
 .B \-m
-Demean: subtract the mean of the samples from each sample.
+Demean: subtract the mean of the samples from each sample. Selecting this 
+option automatically sets the 
+.B \-z
+ option.
 .TP
 .B \-z
 .TP
 .B \-z
-Scale the .wav file output without preserving the zero value
+Scale the .wav file output with preservation of the zero value
 .TP
 .B \-v
 Verbose mode
 .TP
 .B \-v
 Verbose mode
index 510294b9d48406d6ee0f14ba5e8e8c28ef72de9f..ddf75843c78813d9047aa4a94b7ddd34b84c84eb 100644 (file)
@@ -8,7 +8,7 @@
 **
 **  Copyright (c) 2003 Kevin Rosenberg
 **
 **
 **  Copyright (c) 2003 Kevin Rosenberg
 **
-**  $Id: wdq2wav.cpp,v 1.25 2003/02/25 18:24:48 kevin Exp $
+**  $Id: wdq2wav.cpp,v 1.26 2003/02/28 04:12:17 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
 **
 **  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>
 
 
 #include <wdq2wav.h>
 
-const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.25 2003/02/25 18:24:48 kevin Exp $";
+const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.26 2003/02/28 04:12:17 kevin Exp $";
 
 bool g_quiet = false;
 bool g_verbose = false;
 bool g_debug = false;
 
 bool g_quiet = false;
 bool g_verbose = false;
 bool g_debug = false;
-bool g_ignore_zero = false;
+bool g_preserve_zero = false;
 bool g_demean = false;
 
 
 bool g_demean = false;
 
 
@@ -111,8 +111,9 @@ usage (const char* progname)
   std::cout << "OPTIONS\n";
   std::cout << "  -p   Play channel through audio system\n";
   std::cout << "  -q   Supress all messages\n";
   std::cout << "OPTIONS\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 << "  -z   Scale output with preserving zero point\n";
   std::cout << "  -m   Demean the data (subtract the mean value from each sample)\n";
   std::cout << "  -m   Demean the data (subtract the mean value from each sample)\n";
+  std::cout << "       [Selecting this option automatically sets the -z option]\n";
   std::cout << "  -v   Verbose mode\n";
   std::cout << "  -d   Debug mode\n";
   std::cout << "  -r   Print program version\n";
   std::cout << "  -v   Verbose mode\n";
   std::cout << "  -d   Debug mode\n";
   std::cout << "  -r   Print program version\n";
@@ -138,6 +139,10 @@ main (int argc, char *argv[])
       break;
     case 'm':
       g_demean = true;
       break;
     case 'm':
       g_demean = true;
+      g_preserve_zero = true; // auto set
+      break;
+    case 'z':
+      g_preserve_zero = true;
       break;
     case 'v':
       g_verbose = true;
       break;
     case 'v':
       g_verbose = true;
@@ -148,9 +153,6 @@ main (int argc, char *argv[])
     case 'p':
       play = true;
       break;
     case 'p':
       play = true;
       break;
-    case 'z':
-      g_ignore_zero = true;
-      break;
     case 'h':
       usage (progname);
       return (0);
     case 'h':
       usage (progname);
       return (0);
@@ -534,17 +536,17 @@ WavFile::WavFile (WindaqChannel& wdq_channel, const char* fname)
     m_rate = wdq_channel.r_wdq.m_sample_rate;
 
     double data_offset = 0, data_scale = 0;
     m_rate = wdq_channel.r_wdq.m_sample_rate;
 
     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 {
+    if (g_preserve_zero) {
       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);
       if (max_value != 0.)
        data_scale = 32767. / max_value;
       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);
       if (max_value != 0.)
        data_scale = 32767. / max_value;
+    } else {
+      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);
     }
     
     if (g_debug) {
     }
     
     if (g_debug) {
@@ -572,11 +574,12 @@ WavFile::WavFile (WindaqChannel& wdq_channel, const char* fname)
     for (i = 0; i < m_nSamples; i++) {
       double value = input[i];
       value = (slope * value) + intercept;
     for (i = 0; i < m_nSamples; i++) {
       double value = input[i];
       value = (slope * value) + intercept;
-      if (g_ignore_zero) {
+      if (g_preserve_zero) {
+       value = value * data_scale;
+      } else {
        value = (value + data_offset) * data_scale;
        value += 0.5 - 32768;
        value = (value + data_offset) * data_scale;
        value += 0.5 - 32768;
-      } else
-       value = value * data_scale;
+      }
       
       signed short int v = static_cast<signed short int>(value);
 #if WORDS_BIG_ENDIAN
       
       signed short int v = static_cast<signed short int>(value);
 #if WORDS_BIG_ENDIAN