e4d261ff51124798d1472fe657104bf056073e65
[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.5 2003/01/21 07:37:13 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 class WindaqFile
38 {
39 public:
40   WindaqFile (const char* fname);
41   ~WindaqFile ();
42   bool ReadHeader();
43
44   std::string m_strFile;
45   bool m_valid;
46   std::string m_error;
47   int m_fd;
48   unsigned int m_nChannels;
49   unsigned int m_nSamples;
50   double m_sample_rate;
51   unsigned int m_sr_denom, m_sr_numer;
52   unsigned int m_nHeader_bytes, m_channel_offset, m_nBytes_channel_header;
53   unsigned int m_nData_bytes;
54   unsigned long int m_time_acq_start;
55   unsigned long int m_time_acq_stop;
56 };
57
58 class WindaqChannel 
59 {
60 public:
61   bool m_valid;
62   unsigned int m_channel;
63   std::string m_units;
64   double m_slope;
65   double m_intercept;
66   signed short int *m_data;
67   WindaqFile& r_wdq;
68   signed short int m_min_raw_data;
69   signed short int m_max_raw_data;
70   double m_max_scaled_data;
71   double m_min_scaled_data;
72
73   WindaqChannel (WindaqFile& wdq, const int channel);
74   ~WindaqChannel ();
75
76  private:
77   bool read_channel_data();
78 };
79
80
81 class WavFile 
82 {
83  public:
84   std::string m_strFile;
85   int m_fd;
86   bool m_valid;
87   unsigned long int m_nSamples;
88   double m_rate;
89   unsigned int m_nChannels;
90   unsigned int m_nBitsPerSample;
91   unsigned int m_nBytesPerSample;
92   signed short int* m_data;
93
94   WavFile (WindaqChannel& wdq_channel, const char* fname);
95   ~WavFile ();
96
97   bool WriteFile ();
98 };