r4155: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 3 Mar 2003 21:52:09 +0000 (21:52 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 3 Mar 2003 21:52:09 +0000 (21:52 +0000)
debian/changelog
wdq2wav.1
wdq2wav.cpp

index 83b1482b61485151c6d8f95661ee290fee0f1670..3ede89f8f4214e90e411b4dfa0b60028f406e061 100644 (file)
@@ -1,3 +1,9 @@
+wdq2wav (0.7.2-1) unstable; urgency=low
+
+  * Invert the sense of -m and -z
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Mon,  3 Mar 2003 14:49:48 -0700
+
 wdq2wav (0.7.1-1) unstable; urgency=low
 
   * Fix makefile so that html version of man page is no longer
index 2026807a8f949a6e1295eb47b44aa7349015c2ef..3c84c7a5ecdee59394968e6ac25432e9617ca893 100644 (file)
--- a/wdq2wav.1
+++ b/wdq2wav.1
@@ -1,20 +1,5 @@
 .\"                                      Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH WDQ2WAV 1 "January 20, 2003"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh        disable hyphenation
-.\" .hy        enable hyphenation
-.\" .ad l      left justify
-.\" .ad b      justify to both left and right margins
-.\" .nf        disable filling
-.\" .fi        enable filling
-.\" .br        insert line break
-.\" .sp <n>    insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
+.TH WDQ2WAV 1 "March 5, 2003"
 .SH NAME
 wdq2wav \- convert a WinDAQ file channel to a wav file
 .SH SYNOPSIS
@@ -33,13 +18,12 @@ to enter thos values when the program is run.
 Play channel through audio system
 .TP
 .B \-m
-Demean: subtract the mean of the samples from each sample. Selecting this 
-option automatically sets the 
-.B \-z
- option.
+Do not demean. (Don't subtract the mean of the samples from each sample.)
 .TP
 .B \-z
-Scale the .wav file output with preservation of the zero value
+Scale the .wav file output 
+.B *without* 
+preservation of the zero value
 .TP
 .B \-v
 Verbose mode
index ddf75843c78813d9047aa4a94b7ddd34b84c84eb..87ab17783014e1954b5d84499abf34099d677f25 100644 (file)
@@ -8,7 +8,7 @@
 **
 **  Copyright (c) 2003 Kevin Rosenberg
 **
-**  $Id: wdq2wav.cpp,v 1.26 2003/02/28 04:12:17 kevin Exp $
+**  $Id: wdq2wav.cpp,v 1.27 2003/03/03 21:52:09 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.26 2003/02/28 04:12:17 kevin Exp $";
+const char* g_szIdStr = "$Id: wdq2wav.cpp,v 1.27 2003/03/03 21:52:09 kevin Exp $";
 
 bool g_quiet = false;
 bool g_verbose = false;
 bool g_debug = false;
-bool g_preserve_zero = false;
-bool g_demean = false;
+bool g_ignore_zero = false;
+bool g_dont_demean = false;
 
 
 #ifdef WIN32
@@ -111,9 +111,8 @@ 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 << "  -z   Scale output with preserving zero point\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 << "  -z   Scale output without preserving zero point\n";
+  std::cout << "  -m   Do not demean the data (don't subtract the mean value from each sample)\n";
   std::cout << "  -v   Verbose mode\n";
   std::cout << "  -d   Debug mode\n";
   std::cout << "  -r   Print program version\n";
@@ -138,11 +137,10 @@ main (int argc, char *argv[])
       g_quiet = true;
       break;
     case 'm':
-      g_demean = true;
-      g_preserve_zero = true; // auto set
+      g_dont_demean = true;
       break;
     case 'z':
-      g_preserve_zero = true;
+      g_ignore_zero = true;
       break;
     case 'v':
       g_verbose = true;
@@ -510,7 +508,7 @@ WindaqChannel::read_channel_data ()
   m_max_scaled_data = (m_slope * data_max) + m_intercept;
   m_min_scaled_data = (m_slope * data_min) + m_intercept;
 
-  if (g_demean) {
+  if (! g_dont_demean) {
     double dmean = total_data / static_cast<double>(r_wdq.m_nSamples);
     int mean = nearest<int>(dmean);
     std::cout << "Removing mean: " << (dmean * m_slope) + m_intercept <<
@@ -536,17 +534,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;
-    if (g_preserve_zero) {
+    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);
       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) {
@@ -574,11 +572,11 @@ WavFile::WavFile (WindaqChannel& wdq_channel, const char* fname)
     for (i = 0; i < m_nSamples; i++) {
       double value = input[i];
       value = (slope * value) + intercept;
-      if (g_preserve_zero) {
-       value = value * data_scale;
-      } else {
+      if (g_ignore_zero) {
        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);