Debian Codegraph @

source/impdata.h

raw
1 // ----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2003-2013 Fons Adriaensen <[email protected]>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // ----------------------------------------------------------------------------
19
20
21 #ifndef __IMPDATA_H
22 #define __IMPDATA_H
23
24
25 #include <stdio.h>
26 #include <sndfile.h>
27 #include "itypes.h"
28
29
30 class Impdata
31 {
32 public:
33
34 enum
35 {
36 TYPE_RAW = 0x00010000,
37 TYPE_SWEEP = 0x00020002,
38 TYPE_LR = 0x00030002,
39 TYPE_MS = 0x00040002,
40 TYPE_AMB_A = 0x00050004,
41 TYPE_AMB_B3 = 0x00060003,
42 TYPE_AMB_B4 = 0x00070004,
43 TYPE__CHAN = 0x0000ffff,
44 TYPE__TYPE = 0xffff0000
45 };
46
47 enum
48 {
49 ERR_NONE = 0,
50 ERR_MODE = -1,
51 ERR_DATA = -2,
52 ERR_OPEN = -3,
53 ERR_FORM = -4,
54 ERR_SEEK = -5,
55 ERR_READ = -6,
56 ERR_WRITE = -7
57 };
58
59 enum
60 {
61 MODE_NONE = 0,
62 MODE_READ = 1,
63 MODE_WRITE = 2
64 };
65
66 Impdata (void);
67 ~Impdata (void);
68
69 U32 mode (void) const { return _mode; }
70 U32 vers (void) const { return _vers; }
71 U32 type (void) const { return _type; }
72 U32 rate_n (void) const { return _rate_n; }
73 U32 rate_d (void) const { return _rate_d; }
74 U32 n_chan (void) const { return _type & TYPE__CHAN; }
75 U32 n_fram (void) const { return _n_fram; }
76 U32 n_sect (void) const { return _n_sect; }
77 U32 i_fram (void) const { return _i_fram; }
78 U32 i_sect (void) const { return _i_sect; }
79 S32 tref_i (void) const { return _tref_i; }
80 U32 tref_n (void) const { return _tref_n; }
81 U32 tref_d (void) const { return _tref_d; }
82
83 int set_type (U32 type);
84 int set_n_fram (U32 n_fram);
85 int set_n_sect (U32 n_sect);
86 void set_rate (U32 rate_n, U32 rate_d = 1) { _rate_n = rate_n; _rate_d = rate_d; }
87 void set_tref (S32 i, U32 n = 0, U32 d = 1) { _tref_i = i; _tref_n = n; _tref_d = d; }
88 void set_bits (U32 bits) { _bits = bits; }
89
90 double drate (void) const { return (double) _rate_n / (double) _rate_d; }
91 double dtref (void) const { return (double) _tref_n / (double) _tref_d + _tref_i; }
92
93 float *data (int c) const { return _data ? (_data + c) : 0; }
94
95 int alloc (void);
96 int deall (void);
97 int clear (void);
98
99 int open_read (const char *name);
100 int open_write (const char *name);
101 int sf_open_read (const char *name);
102 int sf_open_write (const char *name);
103 int close (void);
104
105 int read_sect (U32 i_sect);
106 int write_sect (U32 i_sect);
107
108 int locate (U32 i_sect);
109 int read_ext (U32 k, float *p);
110 int write_ext (U32 k, float *p);
111
112 static void checkext (char *name);
113 static const char *channame (U32 type, U32 chan);
114
115 private:
116
117 U32 _vers;
118 U32 _type;
119 U32 _rate_n;
120 U32 _rate_d;
121 U32 _n_fram;
122 U32 _n_sect;
123 S32 _tref_i;
124 U32 _tref_n;
125 U32 _tref_d;
126 U32 _bits;
127
128 U32 _i_fram;
129 U32 _i_sect;
130 U32 _mode;
131 U32 _size;
132 float *_data;
133 FILE *_aldfile;
134 SNDFILE *_sndfile;
135
136 static U32 mapvers1 (U32 type);
137
138 static char _suffix [12];
139 static const char *_suffix2 [2];
140 static const char *_suffix3 [2];
141 static const char *_suffix4 [2];
142 static const char *_suffix5 [4];
143 static const char *_suffix7 [4];
144 };
145
146
147 #endif
148