From: Kevin M. Rosenberg Date: Tue, 21 Jan 2003 03:03:49 +0000 (+0000) Subject: r3822: Auto commit for Debian build X-Git-Tag: v0.8.1~53 X-Git-Url: http://git.kpe.io/?p=wdq2wav.git;a=commitdiff_plain;h=c3fb0a2a8050d00a6b3edd41731cea3c2ef5886e r3822: Auto commit for Debian build --- diff --git a/debian/changelog b/debian/changelog index 7ed91ce..72870bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +wdq2wav (0.2-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Mon, 20 Jan 2003 20:03:39 -0700 + wdq2wav (0.1-1) unstable; urgency=low * Initial Release. diff --git a/wdq2wav.cpp b/wdq2wav.cpp index bc0ae3b..326e8d4 100644 --- a/wdq2wav.cpp +++ b/wdq2wav.cpp @@ -13,11 +13,10 @@ ** 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 \n"); + error_msg ("usage: wdq2wav "); } 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; } diff --git a/wdq2wav.h b/wdq2wav.h index 0c35164..e0f2e50 100644 --- a/wdq2wav.h +++ b/wdq2wav.h @@ -4,6 +4,8 @@ #include #include #include +#include + class WindaqFile {