r3831: *** empty log message ***
[wdq2wav.git] / wdq2wav.h
1 /*****************************************************************************
2 ** FILE IDENTIFICATION
3 **
4 **   Name:          wdq2wav.h
5 **   Purpose:       Header file for wdq2wav.cpp
6 **   Programmer:    Kevin Rosenberg <kevin@rosenberg.net>
7 **   Date Started:  Jan 2003
8 **
9 **  Copyright (c) 2003 Kevin Rosenberg
10 **
11 **  $Id: wdq2wav.h,v 1.6 2003/01/21 09:38:59 kevin Exp $
12 **
13 **  This program is free software; you can redistribute it and/or modify
14 **  it under the terms of the GNU General Public License (version 2) as
15 **  published by the Free Software Foundation.
16 **
17 **  This program is distributed in the hope that it will be useful,
18 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 **  GNU General Public License for more details.
21 **
22 **  You should have received a copy of the GNU General Public License
23 **  along with this program; if not, write to the Free Software
24 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25 ******************************************************************************/
26
27 #include <iostream>
28 #include <cstdio>
29 #include <cstring>
30 #include <string>
31 #include <sstream>
32 #include <ctime>
33 #include <fcntl.h>
34 #include <unistd.h>
35 #include <getopt.h>
36
37 extern const char* g_szIdStr;
38 extern bool g_quiet;
39 extern bool g_verbose;
40 extern bool g_debug;
41
42 #define MAX_INPUT_STR 256
43
44 void error_msg (const char *msg);
45 void info_msg (const char *msg);
46 void info_msg_sans_newline (const char *msg);
47
48 bool wdq2wav (const char* wdq_fname, const int channel, const char *wav_fname);
49
50 class WindaqFile
51 {
52 public:
53   WindaqFile (const char* fname);
54   ~WindaqFile ();
55   bool ReadHeader();
56
57   std::string m_strFile;
58   bool m_valid;
59   std::string m_error;
60   int m_fd;
61   unsigned int m_nChannels;
62   unsigned int m_nSamples;
63   double m_sample_rate;
64   unsigned int m_sr_denom, m_sr_numer;
65   unsigned int m_nHeader_bytes, m_channel_offset, m_nBytes_channel_header;
66   unsigned int m_nData_bytes;
67   unsigned long int m_time_acq_start;
68   unsigned long int m_time_acq_stop;
69 };
70
71 class WindaqChannel 
72 {
73 public:
74   bool m_valid;
75   unsigned int m_channel;
76   std::string m_units;
77   double m_slope;
78   double m_intercept;
79   signed short int *m_data;
80   WindaqFile& r_wdq;
81   signed short int m_min_raw_data;
82   signed short int m_max_raw_data;
83   double m_max_scaled_data;
84   double m_min_scaled_data;
85
86   WindaqChannel (WindaqFile& wdq, const int channel);
87   ~WindaqChannel ();
88
89  private:
90   bool read_channel_data();
91 };
92
93
94 class WavFile 
95 {
96  public:
97   std::string m_strFile;
98   int m_fd;
99   bool m_valid;
100   unsigned long int m_nSamples;
101   double m_rate;
102   unsigned int m_nChannels;
103   unsigned int m_nBitsPerSample;
104   unsigned int m_nBytesPerSample;
105   signed short int* m_data;
106
107   WavFile (WindaqChannel& wdq_channel, const char* fname);
108   ~WavFile ();
109
110   bool WriteFile ();
111 };