From c1c969d9db8d0a5fbe02563f7a8cc61d5638890d Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 24 Feb 2003 08:40:25 +0000 Subject: [PATCH] r4107: Auto commit for Debian build --- debian/changelog | 8 +++++++- wdq2wav.cpp | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1414029..056c0bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 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 Tue, 11 Feb 2003 23:06:52 -0700 diff --git a/wdq2wav.cpp b/wdq2wav.cpp index 288a9c6..16eddba 100644 --- a/wdq2wav.cpp +++ b/wdq2wav.cpp @@ -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 @@ -26,11 +26,12 @@ #include -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] \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(value); #if WORDS_BIG_ENDIAN unsigned char* p = reinterpret_cast(&v); -- 2.34.1